@ericblade/quagga2 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/quagga.js +61 -18
- package/dist/quagga.min.js +2 -2
- package/lib/quagga.js +58 -17
- package/package.json +4 -2
- package/type-definitions/quagga.d.ts +19 -2
package/lib/quagga.js
CHANGED
|
@@ -546,6 +546,7 @@ var ImageWrapper = /*#__PURE__*/function () {
|
|
|
546
546
|
key: "show",
|
|
547
547
|
value: function show(canvas) {
|
|
548
548
|
var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1.0;
|
|
549
|
+
console.warn('* imagewrapper show getcontext 2d');
|
|
549
550
|
var ctx = canvas.getContext('2d');
|
|
550
551
|
if (!ctx) {
|
|
551
552
|
throw new Error('Unable to get canvas context');
|
|
@@ -574,6 +575,7 @@ var ImageWrapper = /*#__PURE__*/function () {
|
|
|
574
575
|
var whiteRgb = [255, 255, 255];
|
|
575
576
|
var blackRgb = [0, 0, 0];
|
|
576
577
|
var result = [];
|
|
578
|
+
console.warn('* imagewrapper overlay getcontext 2d');
|
|
577
579
|
var ctx = canvas.getContext('2d');
|
|
578
580
|
if (!ctx) {
|
|
579
581
|
throw new Error('Unable to get canvas context');
|
|
@@ -1264,6 +1266,7 @@ function loadImageArray(src, callback) {
|
|
|
1264
1266
|
canvas.width = this.width;
|
|
1265
1267
|
// eslint-disable-next-line no-param-reassign
|
|
1266
1268
|
canvas.height = this.height;
|
|
1269
|
+
console.warn('* loadImageArray getContext 2d');
|
|
1267
1270
|
var ctx = canvas.getContext('2d');
|
|
1268
1271
|
ctx.drawImage(this, 0, 0);
|
|
1269
1272
|
var array = new Uint8Array(this.width * this.height);
|
|
@@ -1922,7 +1925,11 @@ function initCanvas() {
|
|
|
1922
1925
|
_canvasContainer.dom.binary = document.createElement('canvas');
|
|
1923
1926
|
_canvasContainer.dom.binary.className = 'binaryBuffer';
|
|
1924
1927
|
if (false) {}
|
|
1925
|
-
|
|
1928
|
+
var willReadFrequently = !!_config.willReadFrequently;
|
|
1929
|
+
console.warn('* initCanvas willReadFrequently', willReadFrequently, _config);
|
|
1930
|
+
_canvasContainer.ctx.binary = _canvasContainer.dom.binary.getContext('2d', {
|
|
1931
|
+
willReadFrequently: willReadFrequently
|
|
1932
|
+
});
|
|
1926
1933
|
_canvasContainer.dom.binary.width = _binaryImageWrapper.size.x;
|
|
1927
1934
|
_canvasContainer.dom.binary.height = _binaryImageWrapper.size.y;
|
|
1928
1935
|
}
|
|
@@ -10426,21 +10433,32 @@ var QuaggaJSCameraAccess = {
|
|
|
10426
10433
|
track = getActiveTrack(); // TODO: should we acquire camera access even if there's no current camera open?
|
|
10427
10434
|
// TODO: what happens on iOS or another device where torch isn't supported at all? Should we throw an error?
|
|
10428
10435
|
if (!track) {
|
|
10429
|
-
_context2.next =
|
|
10436
|
+
_context2.next = 11;
|
|
10430
10437
|
break;
|
|
10431
10438
|
}
|
|
10432
|
-
_context2.
|
|
10439
|
+
_context2.prev = 2;
|
|
10440
|
+
_context2.next = 5;
|
|
10433
10441
|
return track.applyConstraints({
|
|
10434
10442
|
advanced: [{
|
|
10435
10443
|
torch: false
|
|
10436
10444
|
}]
|
|
10437
10445
|
});
|
|
10438
|
-
case
|
|
10446
|
+
case 5:
|
|
10447
|
+
_context2.next = 11;
|
|
10448
|
+
break;
|
|
10449
|
+
case 7:
|
|
10450
|
+
_context2.prev = 7;
|
|
10451
|
+
_context2.t0 = _context2["catch"](2);
|
|
10452
|
+
if (_context2.t0 instanceof OverconstrainedError) {
|
|
10453
|
+
console.warn('quagga2/CameraAccess: Torch not supported on this device');
|
|
10454
|
+
}
|
|
10455
|
+
throw _context2.t0;
|
|
10456
|
+
case 11:
|
|
10439
10457
|
case "end":
|
|
10440
10458
|
return _context2.stop();
|
|
10441
10459
|
}
|
|
10442
10460
|
}
|
|
10443
|
-
}, _callee2);
|
|
10461
|
+
}, _callee2, null, [[2, 7]]);
|
|
10444
10462
|
}))();
|
|
10445
10463
|
},
|
|
10446
10464
|
enableTorch: function enableTorch() {
|
|
@@ -10453,21 +10471,32 @@ var QuaggaJSCameraAccess = {
|
|
|
10453
10471
|
track = getActiveTrack(); // TODO: should we acquire camera access even if there's no current camera open?
|
|
10454
10472
|
// TODO: what happens on iOS or another device where torch isn't supported at all? Should we throw an error?
|
|
10455
10473
|
if (!track) {
|
|
10456
|
-
_context3.next =
|
|
10474
|
+
_context3.next = 11;
|
|
10457
10475
|
break;
|
|
10458
10476
|
}
|
|
10459
|
-
_context3.
|
|
10477
|
+
_context3.prev = 2;
|
|
10478
|
+
_context3.next = 5;
|
|
10460
10479
|
return track.applyConstraints({
|
|
10461
10480
|
advanced: [{
|
|
10462
10481
|
torch: true
|
|
10463
10482
|
}]
|
|
10464
10483
|
});
|
|
10465
|
-
case
|
|
10484
|
+
case 5:
|
|
10485
|
+
_context3.next = 11;
|
|
10486
|
+
break;
|
|
10487
|
+
case 7:
|
|
10488
|
+
_context3.prev = 7;
|
|
10489
|
+
_context3.t0 = _context3["catch"](2);
|
|
10490
|
+
if (_context3.t0 instanceof OverconstrainedError) {
|
|
10491
|
+
console.warn('quagga2/CameraAccess: Torch not supported on this device');
|
|
10492
|
+
}
|
|
10493
|
+
throw _context3.t0;
|
|
10494
|
+
case 11:
|
|
10466
10495
|
case "end":
|
|
10467
10496
|
return _context3.stop();
|
|
10468
10497
|
}
|
|
10469
10498
|
}
|
|
10470
|
-
}, _callee3);
|
|
10499
|
+
}, _callee3, null, [[2, 7]]);
|
|
10471
10500
|
}))();
|
|
10472
10501
|
}
|
|
10473
10502
|
};
|
|
@@ -10489,7 +10518,9 @@ function passesFilter(codeResult, filter) {
|
|
|
10489
10518
|
create: function create(config) {
|
|
10490
10519
|
var _config$capacity;
|
|
10491
10520
|
var canvas = document.createElement('canvas');
|
|
10492
|
-
var ctx = canvas.getContext('2d'
|
|
10521
|
+
var ctx = canvas.getContext('2d', {
|
|
10522
|
+
willReadFrequently: !!config.willReadFrequently
|
|
10523
|
+
});
|
|
10493
10524
|
var results = [];
|
|
10494
10525
|
var capacity = (_config$capacity = config.capacity) !== null && _config$capacity !== void 0 ? _config$capacity : 20;
|
|
10495
10526
|
var capture = config.capture === true;
|
|
@@ -10910,18 +10941,26 @@ function findOrCreateCanvas(selector, className) {
|
|
|
10910
10941
|
}
|
|
10911
10942
|
return canvas;
|
|
10912
10943
|
}
|
|
10913
|
-
function getCanvasAndContext(selector, className) {
|
|
10944
|
+
function getCanvasAndContext(selector, className, options) {
|
|
10914
10945
|
var canvas = findOrCreateCanvas(selector, className);
|
|
10915
|
-
|
|
10946
|
+
console.warn('* initCanvas getCanvasAndContext');
|
|
10947
|
+
var context = canvas.getContext('2d', {
|
|
10948
|
+
willReadFrequently: options.willReadFrequently
|
|
10949
|
+
});
|
|
10916
10950
|
return {
|
|
10917
10951
|
canvas: canvas,
|
|
10918
10952
|
context: context
|
|
10919
10953
|
};
|
|
10920
10954
|
}
|
|
10921
|
-
function initCanvases(canvasSize) {
|
|
10955
|
+
function initCanvases(canvasSize, _ref) {
|
|
10956
|
+
var willReadFrequently = _ref.willReadFrequently;
|
|
10922
10957
|
if (typeof document !== 'undefined') {
|
|
10923
|
-
var image = getCanvasAndContext('canvas.imgBuffer', 'imgBuffer'
|
|
10924
|
-
|
|
10958
|
+
var image = getCanvasAndContext('canvas.imgBuffer', 'imgBuffer', {
|
|
10959
|
+
willReadFrequently: willReadFrequently
|
|
10960
|
+
});
|
|
10961
|
+
var overlay = getCanvasAndContext('canvas.drawingBuffer', 'drawingBuffer', {
|
|
10962
|
+
willReadFrequently: willReadFrequently
|
|
10963
|
+
});
|
|
10925
10964
|
|
|
10926
10965
|
// eslint-disable-next-line no-multi-assign
|
|
10927
10966
|
image.canvas.width = overlay.canvas.width = canvasSize.x;
|
|
@@ -10941,11 +10980,13 @@ function initCanvases(canvasSize) {
|
|
|
10941
10980
|
return null;
|
|
10942
10981
|
}
|
|
10943
10982
|
function initCanvas_initCanvas(context) {
|
|
10944
|
-
var _context$config, _context$config$input, _context$config2, _context$config2$inpu;
|
|
10983
|
+
var _context$config, _context$config$input, _context$config2, _context$config2$inpu, _context$config3, _context$config3$inpu;
|
|
10945
10984
|
var viewport = getViewPort_getViewPort(context === null || context === void 0 ? void 0 : (_context$config = context.config) === null || _context$config === void 0 ? void 0 : (_context$config$input = _context$config.inputStream) === null || _context$config$input === void 0 ? void 0 : _context$config$input.target);
|
|
10946
10985
|
var type = context === null || context === void 0 ? void 0 : (_context$config2 = context.config) === null || _context$config2 === void 0 ? void 0 : (_context$config2$inpu = _context$config2.inputStream) === null || _context$config2$inpu === void 0 ? void 0 : _context$config2$inpu.type;
|
|
10947
10986
|
if (!type) return null;
|
|
10948
|
-
var container = initCanvases(context.inputStream.getCanvasSize()
|
|
10987
|
+
var container = initCanvases(context.inputStream.getCanvasSize(), {
|
|
10988
|
+
willReadFrequently: !!(context !== null && context !== void 0 && (_context$config3 = context.config) !== null && _context$config3 !== void 0 && (_context$config3$inpu = _context$config3.inputStream) !== null && _context$config3$inpu !== void 0 && _context$config3$inpu.willReadFrequently)
|
|
10989
|
+
});
|
|
10949
10990
|
if (!container) return {
|
|
10950
10991
|
dom: {
|
|
10951
10992
|
image: null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ericblade/quagga2",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "An advanced barcode-scanner written in JavaScript",
|
|
5
5
|
"main": "lib/quagga.js",
|
|
6
6
|
"types": "type-definitions/quagga.d.ts",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"build:dev": "npx cross-env NODE_ENV=development BUILD_ENV=development webpack --config configs/webpack.config.js",
|
|
77
77
|
"build:prod": "npx cross-env NODE_ENV=production BUILD_ENV=production webpack --config configs/webpack.config.min.js",
|
|
78
78
|
"build:node": "npx cross-env NODE_ENV=production BABEL_ENV=commonjs BUILD_ENV=node webpack --config configs/webpack.node.config.js",
|
|
79
|
+
"build-new": "npx cross-env NODE_OPTIONS=--openssl-legacy-provider npm run build",
|
|
79
80
|
"build": "npm run check-types && npm run build:dev && npm run build:prod && npm run build:node",
|
|
80
81
|
"watch": "npx cross-env BUILD_ENV=development webpack --watch",
|
|
81
82
|
"lint": "eslint src",
|
|
@@ -134,7 +135,8 @@
|
|
|
134
135
|
"Alex Howes <alex@alexhowes.co.uk>",
|
|
135
136
|
"Sudham Jayanthi <workwithsudham@gmail.com>",
|
|
136
137
|
"Ben Khoo <khoobks@gmail.com>",
|
|
137
|
-
"Andy Edinborough <andy@edinborough.org>"
|
|
138
|
+
"Andy Edinborough <andy@edinborough.org>",
|
|
139
|
+
"Claudio Cocciarelli <claudiococciarelli@gmail.com>"
|
|
138
140
|
],
|
|
139
141
|
"license": "MIT",
|
|
140
142
|
"engines": {
|
|
@@ -703,6 +703,7 @@ export interface QuaggaJSResultCollector {
|
|
|
703
703
|
create?(param: QuaggaJSResultCollector): QuaggaJSResultCollector;
|
|
704
704
|
|
|
705
705
|
getResults?(): QuaggaJSCodeResult[];
|
|
706
|
+
willReadFrequently?: boolean;
|
|
706
707
|
}
|
|
707
708
|
|
|
708
709
|
/**
|
|
@@ -869,7 +870,7 @@ export interface QuaggaJSConfigObject {
|
|
|
869
870
|
/**
|
|
870
871
|
* @default [ "code_128_reader" ]
|
|
871
872
|
*/
|
|
872
|
-
readers?: (QuaggaJSReaderConfig |
|
|
873
|
+
readers?: (QuaggaJSReaderConfig | QuaggaJSCodeReader)[];
|
|
873
874
|
|
|
874
875
|
debug?: {
|
|
875
876
|
/**
|
|
@@ -913,7 +914,7 @@ export interface QuaggaJSConfigObject {
|
|
|
913
914
|
* Available values: x-small, small, medium, large, x-large
|
|
914
915
|
*/
|
|
915
916
|
patchSize?: string;
|
|
916
|
-
|
|
917
|
+
willReadFrequently?: boolean;
|
|
917
918
|
debug?: {
|
|
918
919
|
/**
|
|
919
920
|
* @default false
|
|
@@ -1004,3 +1005,19 @@ export type TypedArray =
|
|
|
1004
1005
|
| Uint32Array
|
|
1005
1006
|
| Float32Array
|
|
1006
1007
|
| Float64Array;
|
|
1008
|
+
|
|
1009
|
+
export type QuaggaJSCodeReader =
|
|
1010
|
+
| 'code_128_reader'
|
|
1011
|
+
| 'ean_reader'
|
|
1012
|
+
| 'ean_5_reader'
|
|
1013
|
+
| 'ean_2_reader'
|
|
1014
|
+
| 'ean_8_reader'
|
|
1015
|
+
| 'code_39_reader'
|
|
1016
|
+
| 'code_39_vin_reader'
|
|
1017
|
+
| 'codabar_reader'
|
|
1018
|
+
| 'upc_reader'
|
|
1019
|
+
| 'upc_e_reader'
|
|
1020
|
+
| 'i2of5_reader'
|
|
1021
|
+
| '2of5_reader'
|
|
1022
|
+
| 'code_93_reader'
|
|
1023
|
+
| 'code_32_reader';
|