Add barcode-detector-api-polyfill dependency and update environment variable declarations in SvelteKit project
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
import { Exception, Result } from '@zxing/library';
|
||||
import { IScannerControls } from './IScannerControls';
|
||||
/**
|
||||
* Callback format for continuous decode scan.
|
||||
*/
|
||||
export declare type DecodeContinuouslyCallback = (result: Result | undefined, error: Exception | undefined, controls: IScannerControls) => void;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=DecodeContinuouslyCallback.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DecodeContinuouslyCallback.js","sourceRoot":"","sources":["../../../src/common/DecodeContinuouslyCallback.ts"],"names":[],"mappings":""}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
import { LuminanceSource } from '@zxing/library';
|
||||
export declare class HTMLCanvasElementLuminanceSource extends LuminanceSource {
|
||||
private canvas;
|
||||
private static DEGREE_TO_RADIANS;
|
||||
private static makeBufferFromCanvasImageData;
|
||||
private static toGrayscaleBuffer;
|
||||
private buffer;
|
||||
private tempCanvasElement?;
|
||||
constructor(canvas: HTMLCanvasElement);
|
||||
getRow(y: number, row: Uint8ClampedArray): Uint8ClampedArray;
|
||||
getMatrix(): Uint8ClampedArray;
|
||||
isCropSupported(): boolean;
|
||||
crop(left: number, top: number, width: number, height: number): LuminanceSource;
|
||||
/**
|
||||
* This is always true, since the image is a gray-scale image.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
isRotateSupported(): boolean;
|
||||
rotateCounterClockwise(): LuminanceSource;
|
||||
rotateCounterClockwise45(): LuminanceSource;
|
||||
invert(): LuminanceSource;
|
||||
private getTempCanvasElement;
|
||||
private rotate;
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HTMLCanvasElementLuminanceSource = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
/**/
|
||||
var HTMLCanvasElementLuminanceSource = /** @class */ (function (_super) {
|
||||
__extends(HTMLCanvasElementLuminanceSource, _super);
|
||||
function HTMLCanvasElementLuminanceSource(canvas) {
|
||||
var _this = _super.call(this, canvas.width, canvas.height) || this;
|
||||
_this.canvas = canvas;
|
||||
_this.tempCanvasElement = null;
|
||||
_this.buffer = HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData(canvas);
|
||||
return _this;
|
||||
}
|
||||
HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData = function (canvas) {
|
||||
var canvasCtx;
|
||||
try {
|
||||
canvasCtx = canvas.getContext('2d', { willReadFrequently: true });
|
||||
}
|
||||
catch (e) {
|
||||
canvasCtx = canvas.getContext('2d');
|
||||
}
|
||||
if (!canvasCtx) {
|
||||
throw new Error('Couldn\'t get canvas context.');
|
||||
}
|
||||
var imageData = canvasCtx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
return HTMLCanvasElementLuminanceSource.toGrayscaleBuffer(imageData.data, canvas.width, canvas.height);
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.toGrayscaleBuffer = function (imageBuffer, width, height) {
|
||||
var grayscaleBuffer = new Uint8ClampedArray(width * height);
|
||||
for (var i = 0, j = 0, length_1 = imageBuffer.length; i < length_1; i += 4, j++) {
|
||||
var gray = void 0;
|
||||
var alpha = imageBuffer[i + 3];
|
||||
// The color of fully-transparent pixels is irrelevant. They are often, technically, fully-transparent
|
||||
// black (0 alpha, and then 0 RGB). They are often used, of course as the "white" area in a
|
||||
// barcode image. Force any such pixel to be white:
|
||||
if (alpha === 0) {
|
||||
gray = 0xFF;
|
||||
}
|
||||
else {
|
||||
var pixelR = imageBuffer[i];
|
||||
var pixelG = imageBuffer[i + 1];
|
||||
var pixelB = imageBuffer[i + 2];
|
||||
// .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
|
||||
// (306*R) >> 10 is approximately equal to R*0.299, and so on.
|
||||
// 0x200 >> 10 is 0.5, it implements rounding.
|
||||
// tslint:disable-next-line:no-bitwise
|
||||
gray = (306 * pixelR + 601 * pixelG + 117 * pixelB + 0x200) >> 10;
|
||||
}
|
||||
grayscaleBuffer[j] = gray;
|
||||
}
|
||||
return grayscaleBuffer;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.getRow = function (y /*int*/, row) {
|
||||
if (y < 0 || y >= this.getHeight()) {
|
||||
throw new library_1.IllegalArgumentException('Requested row is outside the image: ' + y);
|
||||
}
|
||||
var width = this.getWidth();
|
||||
var start = y * width;
|
||||
if (row === null) {
|
||||
row = this.buffer.slice(start, start + width);
|
||||
}
|
||||
else {
|
||||
if (row.length < width) {
|
||||
row = new Uint8ClampedArray(width);
|
||||
}
|
||||
// The underlying raster of image consists of bytes with the luminance values
|
||||
// TODO: can avoid set/slice?
|
||||
row.set(this.buffer.slice(start, start + width));
|
||||
}
|
||||
return row;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.getMatrix = function () {
|
||||
return this.buffer;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.isCropSupported = function () {
|
||||
return true;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.crop = function (left /*int*/, top /*int*/, width /*int*/, height /*int*/) {
|
||||
_super.prototype.crop.call(this, left, top, width, height);
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* This is always true, since the image is a gray-scale image.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
HTMLCanvasElementLuminanceSource.prototype.isRotateSupported = function () {
|
||||
return true;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.rotateCounterClockwise = function () {
|
||||
this.rotate(-90);
|
||||
return this;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.rotateCounterClockwise45 = function () {
|
||||
this.rotate(-45);
|
||||
return this;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.invert = function () {
|
||||
return new library_1.InvertedLuminanceSource(this);
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.getTempCanvasElement = function () {
|
||||
if (null === this.tempCanvasElement) {
|
||||
var tempCanvasElement = this.canvas.ownerDocument.createElement('canvas');
|
||||
tempCanvasElement.width = this.canvas.width;
|
||||
tempCanvasElement.height = this.canvas.height;
|
||||
this.tempCanvasElement = tempCanvasElement;
|
||||
}
|
||||
return this.tempCanvasElement;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.prototype.rotate = function (angle) {
|
||||
var tempCanvasElement = this.getTempCanvasElement();
|
||||
if (!tempCanvasElement) {
|
||||
throw new Error('Could not create a Canvas element.');
|
||||
}
|
||||
var angleRadians = angle * HTMLCanvasElementLuminanceSource.DEGREE_TO_RADIANS;
|
||||
// Calculate and set new dimensions for temp canvas
|
||||
var width = this.canvas.width;
|
||||
var height = this.canvas.height;
|
||||
var newWidth = Math.ceil(Math.abs(Math.cos(angleRadians)) * width + Math.abs(Math.sin(angleRadians)) * height);
|
||||
var newHeight = Math.ceil(Math.abs(Math.sin(angleRadians)) * width + Math.abs(Math.cos(angleRadians)) * height);
|
||||
tempCanvasElement.width = newWidth;
|
||||
tempCanvasElement.height = newHeight;
|
||||
var tempContext = tempCanvasElement.getContext('2d');
|
||||
if (!tempContext) {
|
||||
throw new Error('Could not create a Canvas Context element.');
|
||||
}
|
||||
// Draw at center of temp canvas to prevent clipping of image data
|
||||
tempContext.translate(newWidth / 2, newHeight / 2);
|
||||
tempContext.rotate(angleRadians);
|
||||
tempContext.drawImage(this.canvas, width / -2, height / -2);
|
||||
this.buffer = HTMLCanvasElementLuminanceSource.makeBufferFromCanvasImageData(tempCanvasElement);
|
||||
return this;
|
||||
};
|
||||
HTMLCanvasElementLuminanceSource.DEGREE_TO_RADIANS = Math.PI / 180;
|
||||
return HTMLCanvasElementLuminanceSource;
|
||||
}(library_1.LuminanceSource));
|
||||
exports.HTMLCanvasElementLuminanceSource = HTMLCanvasElementLuminanceSource;
|
||||
//# sourceMappingURL=HTMLCanvasElementLuminanceSource.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTMLCanvasElementLuminanceSource.js","sourceRoot":"","sources":["../../../src/common/HTMLCanvasElementLuminanceSource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAIwB;AAExB,IAAI;AACJ;IAAsD,oDAAe;IA+CnE,0CAA2B,MAAyB;QAApD,YACE,kBAAM,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,SAEnC;QAH0B,YAAM,GAAN,MAAM,CAAmB;QAF5C,uBAAiB,GAAuB,IAAI,CAAC;QAInD,KAAI,CAAC,MAAM,GAAG,gCAAgC,CAAC,6BAA6B,CAAC,MAAM,CAAC,CAAC;;IACvF,CAAC;IA9Cc,8DAA6B,GAA5C,UAA6C,MAAyB;QACpE,IAAI,SAAS,CAAC;QAEd,IAAI;YACF,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;SACnE;QAAC,OAAO,CAAC,EAAE;YACV,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACrC;QAED,IAAI,CAAC,SAAS,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC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GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,MAAM,CACrF,CAAC;QACF,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,GAAG,MAAM,CACrF,CAAC;QACF,iBAAiB,CAAC,KAAK,GAAG,QAAQ,CAAC;QACnC,iBAAiB,CAAC,MAAM,GAAG,SAAS,CAAC;QAErC,IAAM,WAAW,GAAG,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,WAAW,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;SAAE;QAEpF,kEAAkE;QAClE,WAAW,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;QACnD,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACjC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,GAAG,gCAAgC,CAAC,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC;IACd,CAAC;IApJc,kDAAiB,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;IAqJnD,uCAAC;CAAA,AAvJD,CAAsD,yBAAe,GAuJpE;AAvJY,4EAAgC"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* HTML elements that can be decoded.
|
||||
*/
|
||||
export declare type HTMLVisualMediaElement = HTMLVideoElement | HTMLImageElement;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=HTMLVisualMediaElement.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HTMLVisualMediaElement.js","sourceRoot":"","sources":["../../../src/common/HTMLVisualMediaElement.ts"],"names":[],"mappings":""}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
export interface IScannerControls {
|
||||
/**
|
||||
* Stops the scan process loop.
|
||||
*/
|
||||
stop: () => void;
|
||||
/**
|
||||
* @experimental This is highly unstable and Torch support is not ready on browsers. Use at YOUR OWN risk.
|
||||
*/
|
||||
switchTorch?: (onOff: boolean) => Promise<void>;
|
||||
/**
|
||||
* Allows to apply constraints to all tracks or filtered tracks in the stream.
|
||||
* @experimental
|
||||
*/
|
||||
streamVideoConstraintsApply?: (constraints: MediaTrackConstraints, trackFilter?: (track: MediaStreamTrack) => MediaStreamTrack[]) => void;
|
||||
/**
|
||||
* Get the desired track constraints.
|
||||
* @experimental
|
||||
*/
|
||||
streamVideoConstraintsGet?: (trackFilter: (track: MediaStreamTrack) => MediaStreamTrack[]) => MediaTrackConstraints;
|
||||
/**
|
||||
* Get the desired track settings.
|
||||
* @experimental
|
||||
*/
|
||||
streamVideoSettingsGet?: (trackFilter: (track: MediaStreamTrack) => MediaStreamTrack[]) => MediaTrackSettings;
|
||||
/**
|
||||
* Get the desired track capabilities.
|
||||
* @experimental
|
||||
*/
|
||||
streamVideoCapabilitiesGet?: (trackFilter: (track: MediaStreamTrack) => MediaStreamTrack[]) => MediaTrackCapabilities;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IScannerControls.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"IScannerControls.js","sourceRoot":"","sources":["../../../src/common/IScannerControls.ts"],"names":[],"mappings":""}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* If navigator is present.
|
||||
*/
|
||||
export declare function hasNavigator(): boolean;
|
||||
/**
|
||||
* If enumerateDevices under navigator is supported.
|
||||
*/
|
||||
export declare function canEnumerateDevices(): boolean;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.canEnumerateDevices = exports.hasNavigator = void 0;
|
||||
/**
|
||||
* If navigator is present.
|
||||
*/
|
||||
function hasNavigator() {
|
||||
return typeof navigator !== 'undefined';
|
||||
}
|
||||
exports.hasNavigator = hasNavigator;
|
||||
/**
|
||||
* If mediaDevices under navigator is supported.
|
||||
*/
|
||||
function isMediaDevicesSupported() {
|
||||
return hasNavigator() && !!navigator.mediaDevices;
|
||||
}
|
||||
/**
|
||||
* If enumerateDevices under navigator is supported.
|
||||
*/
|
||||
function canEnumerateDevices() {
|
||||
return !!(isMediaDevicesSupported() && navigator.mediaDevices.enumerateDevices);
|
||||
}
|
||||
exports.canEnumerateDevices = canEnumerateDevices;
|
||||
//# sourceMappingURL=navigator-utils.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"navigator-utils.js","sourceRoot":"","sources":["../../../src/common/navigator-utils.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,YAAY;IAC1B,OAAO,OAAO,SAAS,KAAK,WAAW,CAAC;AAC1C,CAAC;AAFD,oCAEC;AACD;;GAEG;AACH,SAAS,uBAAuB;IAC9B,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC;AACpD,CAAC;AACD;;GAEG;AACH,SAAgB,mBAAmB;IACjC,OAAO,CAAC,CAAC,CAAC,uBAAuB,EAAE,IAAI,SAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAClF,CAAC;AAFD,kDAEC"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
export { BarcodeFormat } from '@zxing/library';
|
||||
export * from './common/HTMLCanvasElementLuminanceSource';
|
||||
export * from './common/HTMLVisualMediaElement';
|
||||
export * from './common/IScannerControls';
|
||||
export * from './readers/BrowserAztecCodeReader';
|
||||
export * from './readers/BrowserMultiFormatOneDReader';
|
||||
export * from './readers/BrowserCodeReader';
|
||||
export * from './readers/BrowserDatamatrixCodeReader';
|
||||
export * from './readers/BrowserMultiFormatReader';
|
||||
export * from './readers/BrowserPDF417Reader';
|
||||
export * from './readers/BrowserQRCodeReader';
|
||||
export * from './readers/IBrowserCodeReaderOptions';
|
||||
export * from './writers/BrowserCodeSvgWriter';
|
||||
export * from './writers/BrowserQRCodeSvgWriter';
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
// public API
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BarcodeFormat = void 0;
|
||||
// core
|
||||
var library_1 = require("@zxing/library");
|
||||
Object.defineProperty(exports, "BarcodeFormat", { enumerable: true, get: function () { return library_1.BarcodeFormat; } });
|
||||
// common
|
||||
__exportStar(require("./common/HTMLCanvasElementLuminanceSource"), exports);
|
||||
__exportStar(require("./common/HTMLVisualMediaElement"), exports);
|
||||
__exportStar(require("./common/IScannerControls"), exports);
|
||||
// readers
|
||||
__exportStar(require("./readers/BrowserAztecCodeReader"), exports);
|
||||
__exportStar(require("./readers/BrowserMultiFormatOneDReader"), exports);
|
||||
__exportStar(require("./readers/BrowserCodeReader"), exports);
|
||||
__exportStar(require("./readers/BrowserDatamatrixCodeReader"), exports);
|
||||
__exportStar(require("./readers/BrowserMultiFormatReader"), exports);
|
||||
__exportStar(require("./readers/BrowserPDF417Reader"), exports);
|
||||
__exportStar(require("./readers/BrowserQRCodeReader"), exports);
|
||||
__exportStar(require("./readers/IBrowserCodeReaderOptions"), exports);
|
||||
// writers
|
||||
__exportStar(require("./writers/BrowserCodeSvgWriter"), exports);
|
||||
__exportStar(require("./writers/BrowserQRCodeSvgWriter"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,aAAa;;;;;;;;;;;;;AAEb,OAAO;AACP,0CAA+C;AAAtC,wGAAA,aAAa,OAAA;AAEtB,SAAS;AACT,4EAA0D;AAC1D,kEAAgD;AAChD,4DAA0C;AAE1C,UAAU;AACV,mEAAiD;AACjD,yEAAuD;AACvD,8DAA4C;AAC5C,wEAAsD;AACtD,qEAAmD;AACnD,gEAA8C;AAC9C,gEAA8C;AAC9C,sEAAoD;AAEpD,UAAU;AACV,iEAA+C;AAC/C,mEAAiD"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { DecodeHintType } from '@zxing/library';
|
||||
import { BrowserCodeReader } from './BrowserCodeReader';
|
||||
import { IBrowserCodeReaderOptions } from './IBrowserCodeReaderOptions';
|
||||
/**
|
||||
* Aztec Code reader to use from browser.
|
||||
*
|
||||
* @class BrowserAztecCodeReader
|
||||
* @extends {BrowserCodeReader}
|
||||
*/
|
||||
export declare class BrowserAztecCodeReader extends BrowserCodeReader {
|
||||
/**
|
||||
* Creates an instance of BrowserAztecCodeReader.
|
||||
*/
|
||||
constructor(hints?: Map<DecodeHintType, any>, options?: IBrowserCodeReaderOptions);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserAztecCodeReader = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var BrowserCodeReader_1 = require("./BrowserCodeReader");
|
||||
/**
|
||||
* Aztec Code reader to use from browser.
|
||||
*
|
||||
* @class BrowserAztecCodeReader
|
||||
* @extends {BrowserCodeReader}
|
||||
*/
|
||||
var BrowserAztecCodeReader = /** @class */ (function (_super) {
|
||||
__extends(BrowserAztecCodeReader, _super);
|
||||
/**
|
||||
* Creates an instance of BrowserAztecCodeReader.
|
||||
*/
|
||||
function BrowserAztecCodeReader(hints, options) {
|
||||
return _super.call(this, new library_1.AztecCodeReader(), hints, options) || this;
|
||||
}
|
||||
return BrowserAztecCodeReader;
|
||||
}(BrowserCodeReader_1.BrowserCodeReader));
|
||||
exports.BrowserAztecCodeReader = BrowserAztecCodeReader;
|
||||
//# sourceMappingURL=BrowserAztecCodeReader.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserAztecCodeReader.js","sourceRoot":"","sources":["../../../src/readers/BrowserAztecCodeReader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAAiE;AACjE,yDAAwD;AAGxD;;;;;GAKG;AACH;IAA4C,0CAAiB;IAC3D;;OAEG;IACH,gCACE,KAAgC,EAChC,OAAmC;eAEnC,kBAAM,IAAI,yBAAe,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC;IAC9C,CAAC;IACH,6BAAC;AAAD,CAAC,AAVD,CAA4C,qCAAiB,GAU5D;AAVY,wDAAsB"}
|
||||
+283
@@ -0,0 +1,283 @@
|
||||
import { BarcodeFormat, BinaryBitmap, DecodeHintType, Reader, Result } from '@zxing/library';
|
||||
import { DecodeContinuouslyCallback } from '../common/DecodeContinuouslyCallback';
|
||||
import { HTMLVisualMediaElement } from '../common/HTMLVisualMediaElement';
|
||||
import { IScannerControls } from '../common/IScannerControls';
|
||||
import { IBrowserCodeReaderOptions } from './IBrowserCodeReaderOptions';
|
||||
/**
|
||||
* Base class for browser code reader.
|
||||
*/
|
||||
export declare class BrowserCodeReader {
|
||||
protected readonly reader: Reader;
|
||||
hints: Map<DecodeHintType, any>;
|
||||
/**
|
||||
* Allows to change the possible formats the decoder should
|
||||
* search for while scanning some image. Useful for changing
|
||||
* the possible formats during BrowserCodeReader::scan.
|
||||
*/
|
||||
set possibleFormats(formats: BarcodeFormat[]);
|
||||
/**
|
||||
* Defines what the videoElement src will be.
|
||||
*
|
||||
* @param videoElement
|
||||
* @param stream The stream to be added as a source.
|
||||
*/
|
||||
static addVideoSource(videoElement: HTMLVideoElement, stream: MediaStream): void;
|
||||
/**
|
||||
* Enables or disables the torch in a media stream.
|
||||
*
|
||||
* @experimental This doesn't work across all browsers and is still a Draft.
|
||||
*/
|
||||
static mediaStreamSetTorch(track: MediaStreamTrack, onOff: boolean): Promise<void>;
|
||||
/**
|
||||
* Checks if the stream has torch support.
|
||||
*/
|
||||
static mediaStreamIsTorchCompatible(params: MediaStream): boolean;
|
||||
/**
|
||||
*
|
||||
* @param track The media stream track that will be checked for compatibility.
|
||||
*/
|
||||
static mediaStreamIsTorchCompatibleTrack(track: MediaStreamTrack): boolean;
|
||||
/**
|
||||
* Checks if the given video element is currently playing.
|
||||
*/
|
||||
static isVideoPlaying(video: HTMLVideoElement): boolean;
|
||||
/**
|
||||
* Searches and validates a media element.
|
||||
*/
|
||||
static getMediaElement(mediaElementId: string, type: string): HTMLVisualMediaElement;
|
||||
/**
|
||||
* Receives a source and makes sure to return a Video Element from it or fail.
|
||||
*/
|
||||
static createVideoElement(videoThingy?: HTMLVideoElement | string): HTMLVideoElement;
|
||||
/**
|
||||
* Receives a source and makes sure to return an Image Element from it or fail.
|
||||
*/
|
||||
static prepareImageElement(imageSource?: HTMLImageElement | string): HTMLImageElement;
|
||||
/**
|
||||
* Sets a HTMLVideoElement for scanning or creates a new one.
|
||||
*
|
||||
* @param videoElem The HTMLVideoElement to be set.
|
||||
*/
|
||||
static prepareVideoElement(videoElem?: HTMLVideoElement | string): HTMLVideoElement;
|
||||
/**
|
||||
* Checks if and HTML image is loaded.
|
||||
*/
|
||||
static isImageLoaded(img: HTMLImageElement): boolean;
|
||||
/**
|
||||
* Creates a binaryBitmap based in a canvas.
|
||||
*
|
||||
* @param canvas HTML canvas element containing the image source draw.
|
||||
*/
|
||||
static createBinaryBitmapFromCanvas(canvas: HTMLCanvasElement): BinaryBitmap;
|
||||
/**
|
||||
* Overwriting this allows you to manipulate the snapshot image in anyway you want before decode.
|
||||
*/
|
||||
static drawImageOnCanvas(canvasElementContext: CanvasRenderingContext2D, srcElement: HTMLVisualMediaElement): void;
|
||||
static getMediaElementDimensions(mediaElement: HTMLVisualMediaElement): {
|
||||
height: number;
|
||||
width: number;
|
||||
};
|
||||
/**
|
||||
* 🖌 Prepares the canvas for capture and scan frames.
|
||||
*/
|
||||
static createCaptureCanvas(mediaElement: HTMLVisualMediaElement): HTMLCanvasElement;
|
||||
/**
|
||||
* Just tries to play the video and logs any errors.
|
||||
* The play call is only made is the video is not already playing.
|
||||
*/
|
||||
static tryPlayVideo(videoElement: HTMLVideoElement): Promise<boolean>;
|
||||
/**
|
||||
* Creates a canvas and draws the current image frame from the media element on it.
|
||||
*
|
||||
* @param mediaElement HTML media element to extract an image frame from.
|
||||
*/
|
||||
static createCanvasFromMediaElement(mediaElement: HTMLVisualMediaElement): HTMLCanvasElement;
|
||||
/**
|
||||
* Creates a binaryBitmap based in some image source.
|
||||
*
|
||||
* @param mediaElement HTML element containing drawable image source.
|
||||
*/
|
||||
static createBinaryBitmapFromMediaElem(mediaElement: HTMLVisualMediaElement): BinaryBitmap;
|
||||
static destroyImageElement(imageElement: HTMLImageElement): void;
|
||||
/**
|
||||
* Lists all the available video input devices.
|
||||
*/
|
||||
static listVideoInputDevices(): Promise<MediaDeviceInfo[]>;
|
||||
/**
|
||||
* Let's you find a device using it's Id.
|
||||
*/
|
||||
static findDeviceById(deviceId: string): Promise<MediaDeviceInfo | undefined>;
|
||||
/**
|
||||
* Unbinds a HTML video src property.
|
||||
*/
|
||||
static cleanVideoSource(videoElement: HTMLVideoElement): void;
|
||||
/**
|
||||
* Stops all media streams that are created.
|
||||
*/
|
||||
static releaseAllStreams(): void;
|
||||
/**
|
||||
* Waits for a video to load and then hits play on it.
|
||||
* To accomplish that, it binds listeners and callbacks to the video element.
|
||||
*
|
||||
* @param element The video element.
|
||||
* @param callbackFn Callback invoked when the video is played.
|
||||
*/
|
||||
protected static playVideoOnLoadAsync(element: HTMLVideoElement, timeout: number): Promise<boolean>;
|
||||
/**
|
||||
* Sets the new stream and request a new decoding-with-delay.
|
||||
*
|
||||
* @param stream The stream to be shown in the video element.
|
||||
* @param decodeFn A callback for the decode method.
|
||||
*/
|
||||
protected static attachStreamToVideo(stream: MediaStream, preview?: string | HTMLVideoElement, previewPlayTimeout?: number): Promise<HTMLVideoElement>;
|
||||
/**
|
||||
* Keeps track to created media streams.
|
||||
* @private there is no need this array to be accessible from outside.
|
||||
*/
|
||||
private static streamTracker;
|
||||
/**
|
||||
* Returns a Promise that resolves when the given image element loads.
|
||||
*/
|
||||
private static _waitImageLoad;
|
||||
/**
|
||||
* Checks if the `callbackFn` is defined, otherwise throws.
|
||||
*/
|
||||
private static checkCallbackFnOrThrow;
|
||||
/**
|
||||
* Standard method to dispose a media stream object.
|
||||
*/
|
||||
private static disposeMediaStream;
|
||||
/**
|
||||
* BrowserCodeReader specific configuration options.
|
||||
*/
|
||||
protected readonly options: IBrowserCodeReaderOptions;
|
||||
/**
|
||||
* Creates an instance of BrowserCodeReader.
|
||||
* @param {Reader} reader The reader instance to decode the barcode
|
||||
* @param hints Holds the hints the user sets for the Reader.
|
||||
*/
|
||||
constructor(reader: Reader, hints?: Map<DecodeHintType, any>, options?: IBrowserCodeReaderOptions);
|
||||
/**
|
||||
* Gets the BinaryBitmap for ya! (and decodes it)
|
||||
*/
|
||||
decode(element: HTMLVisualMediaElement): Result;
|
||||
/**
|
||||
* Call the encapsulated readers decode
|
||||
*/
|
||||
decodeBitmap(binaryBitmap: BinaryBitmap): Result;
|
||||
/**
|
||||
* Decodes some barcode from a canvas!
|
||||
*/
|
||||
decodeFromCanvas(canvas: HTMLCanvasElement): Result;
|
||||
/**
|
||||
* Decodes something from an image HTML element.
|
||||
*/
|
||||
decodeFromImageElement(source: string | HTMLImageElement): Promise<Result>;
|
||||
/**
|
||||
* Decodes an image from a URL.
|
||||
*/
|
||||
decodeFromImageUrl(url?: string): Promise<Result>;
|
||||
/**
|
||||
* Continuously tries to decode the barcode from a stream obtained from the given constraints
|
||||
* while showing the video in the specified video element.
|
||||
*
|
||||
* @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from
|
||||
* @param {string|HTMLVideoElement} [previewElem] the video element in page where to show the video while
|
||||
* decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined, in
|
||||
* which case no video will be shown.
|
||||
*/
|
||||
decodeFromConstraints(constraints: MediaStreamConstraints, previewElem: string | HTMLVideoElement | undefined, callbackFn: DecodeContinuouslyCallback): Promise<IScannerControls>;
|
||||
/**
|
||||
* In one attempt, tries to decode the barcode from a stream obtained from the given constraints
|
||||
* while showing the video in the specified video element.
|
||||
*
|
||||
* @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from
|
||||
* @param {string|HTMLVideoElement} [preview] the video element in page where to show the video
|
||||
* while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined,
|
||||
* in which case no video will be shown.
|
||||
*/
|
||||
decodeFromStream(stream: MediaStream, preview: string | HTMLVideoElement | undefined, callbackFn: DecodeContinuouslyCallback): Promise<IScannerControls>;
|
||||
/**
|
||||
* Continuously tries to decode the barcode from the device specified by device while showing
|
||||
* the video in the specified video element.
|
||||
*
|
||||
* @param {string|null} [deviceId] the id of one of the devices obtained after calling
|
||||
* getVideoInputDevices. Can be undefined, in this case it will decode from one of the
|
||||
* available devices, preferring the main camera (environment facing) if available.
|
||||
* @param {string|HTMLVideoElement|null} [video] the video element in page where to show the video
|
||||
* while decoding. Can be either an element id or directly an HTMLVideoElement. Can be undefined,
|
||||
* in which case no video will be shown.
|
||||
*/
|
||||
decodeFromVideoDevice(deviceId: string | undefined, previewElem: string | HTMLVideoElement | undefined, callbackFn: DecodeContinuouslyCallback): Promise<IScannerControls>;
|
||||
/**
|
||||
* Decodes something from an image HTML element.
|
||||
*/
|
||||
decodeFromVideoElement(source: string | HTMLVideoElement, callbackFn: DecodeContinuouslyCallback): Promise<IScannerControls>;
|
||||
/**
|
||||
* Decodes a video from a URL until it ends.
|
||||
*/
|
||||
decodeFromVideoUrl(url: string, callbackFn: DecodeContinuouslyCallback): Promise<IScannerControls>;
|
||||
/**
|
||||
* In one attempt, tries to decode the barcode from a stream obtained from the given
|
||||
* constraints while showing the video in the specified video element.
|
||||
*
|
||||
* @param constraints the media stream constraints to get s valid media stream to decode from
|
||||
* @param videoSource the video element in page where to show the video while decoding.
|
||||
* Can be either an element id or directly an HTMLVideoElement. Can be undefined,
|
||||
* in which case no video will be shown.
|
||||
* The decoding result.
|
||||
*/
|
||||
decodeOnceFromConstraints(constraints: MediaStreamConstraints, videoSource?: string | HTMLVideoElement): Promise<Result>;
|
||||
/**
|
||||
* In one attempt, tries to decode the barcode from a stream obtained from the given
|
||||
* constraints while showing the video in the specified video element.
|
||||
*
|
||||
* @param {MediaStream} [constraints] the media stream constraints to get s valid media stream to decode from
|
||||
* @param {string|HTMLVideoElement} [video] the video element in page where to show the video while decoding.
|
||||
* Can be either an element id or directly an HTMLVideoElement. Can be undefined,
|
||||
* in which case no video will be shown.
|
||||
*/
|
||||
decodeOnceFromStream(stream: MediaStream, preview?: string | HTMLVideoElement): Promise<Result>;
|
||||
/**
|
||||
* In one attempt, tries to decode the barcode from the device specified by deviceId
|
||||
* while showing the video in the specified video element.
|
||||
*
|
||||
* @param deviceId the id of one of the devices obtained after calling getVideoInputDevices.
|
||||
* Can be undefined, in this case it will decode from one of the available devices,
|
||||
* preferring the main camera (environment facing) if available.
|
||||
* @param videoSource the video element in page where to show the video while decoding.
|
||||
* Can be either an element id or directly an HTMLVideoElement. Can be undefined,
|
||||
* in which case no video will be shown.
|
||||
*/
|
||||
decodeOnceFromVideoDevice(deviceId?: string, videoSource?: string | HTMLVideoElement): Promise<Result>;
|
||||
/**
|
||||
* Decodes something from an image HTML element.
|
||||
*/
|
||||
decodeOnceFromVideoElement(source: string | HTMLVideoElement): Promise<Result>;
|
||||
/**
|
||||
* Decodes a video from a URL.
|
||||
*/
|
||||
decodeOnceFromVideoUrl(url: string): Promise<Result>;
|
||||
/**
|
||||
* Tries to decode from the video input until it finds some value.
|
||||
*/
|
||||
scanOneResult(element: HTMLVisualMediaElement, retryIfNotFound?: boolean, retryIfChecksumError?: boolean, retryIfFormatError?: boolean): Promise<Result>;
|
||||
/**
|
||||
* Continuously decodes from video input.
|
||||
*
|
||||
* @param element HTML element to scan/decode from. It will not be disposed or destroyed.
|
||||
* @param callbackFn Called after every scan attempt, being it successful or errored.
|
||||
* @param finalizeCallback Called after scan process reaches the end or stop is called.
|
||||
*/
|
||||
scan(element: HTMLVisualMediaElement, callbackFn: DecodeContinuouslyCallback, finalizeCallback?: (error?: Error) => void): IScannerControls;
|
||||
/**
|
||||
* Waits for the image to load and then tries to decode it.
|
||||
*/
|
||||
private _decodeOnLoadImage;
|
||||
/**
|
||||
* Get MediaStream from browser to be used.
|
||||
* @param constraints constraints the media stream constraints to get s valid media stream to decode from.
|
||||
* @private For private use.
|
||||
*/
|
||||
private getUserMedia;
|
||||
}
|
||||
+1203
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+12
@@ -0,0 +1,12 @@
|
||||
import { DecodeHintType } from '@zxing/library';
|
||||
import { BrowserCodeReader } from './BrowserCodeReader';
|
||||
import { IBrowserCodeReaderOptions } from './IBrowserCodeReaderOptions';
|
||||
/**
|
||||
* QR Code reader to use from browser.
|
||||
*/
|
||||
export declare class BrowserDatamatrixCodeReader extends BrowserCodeReader {
|
||||
/**
|
||||
* Creates an instance of BrowserQRCodeReader.
|
||||
*/
|
||||
constructor(hints?: Map<DecodeHintType, any>, options?: IBrowserCodeReaderOptions);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserDatamatrixCodeReader = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var BrowserCodeReader_1 = require("./BrowserCodeReader");
|
||||
/**
|
||||
* QR Code reader to use from browser.
|
||||
*/
|
||||
var BrowserDatamatrixCodeReader = /** @class */ (function (_super) {
|
||||
__extends(BrowserDatamatrixCodeReader, _super);
|
||||
/**
|
||||
* Creates an instance of BrowserQRCodeReader.
|
||||
*/
|
||||
function BrowserDatamatrixCodeReader(hints, options) {
|
||||
return _super.call(this, new library_1.DataMatrixReader(), hints, options) || this;
|
||||
}
|
||||
return BrowserDatamatrixCodeReader;
|
||||
}(BrowserCodeReader_1.BrowserCodeReader));
|
||||
exports.BrowserDatamatrixCodeReader = BrowserDatamatrixCodeReader;
|
||||
//# sourceMappingURL=BrowserDatamatrixCodeReader.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserDatamatrixCodeReader.js","sourceRoot":"","sources":["../../../src/readers/BrowserDatamatrixCodeReader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAAkE;AAClE,yDAAwD;AAGxD;;GAEG;AACH;IAAiD,+CAAiB;IAChE;;OAEG;IACH,qCACE,KAAgC,EAChC,OAAmC;eAEnC,kBAAM,IAAI,0BAAgB,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC;IAC/C,CAAC;IACH,kCAAC;AAAD,CAAC,AAVD,CAAiD,qCAAiB,GAUjE;AAVY,kEAA2B"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { DecodeHintType } from '@zxing/library';
|
||||
import { BrowserCodeReader } from './BrowserCodeReader';
|
||||
import { IBrowserCodeReaderOptions } from './IBrowserCodeReaderOptions';
|
||||
/**
|
||||
* Reader to be used for any One Dimension type barcode.
|
||||
*/
|
||||
export declare class BrowserMultiFormatOneDReader extends BrowserCodeReader {
|
||||
/**
|
||||
* Creates an instance of BrowserBarcodeReader.
|
||||
* @param {Map<DecodeHintType, any>} hints?
|
||||
* @param options
|
||||
*/
|
||||
constructor(hints?: Map<DecodeHintType, any>, options?: IBrowserCodeReaderOptions);
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserMultiFormatOneDReader = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var BrowserCodeReader_1 = require("./BrowserCodeReader");
|
||||
/**
|
||||
* Reader to be used for any One Dimension type barcode.
|
||||
*/
|
||||
var BrowserMultiFormatOneDReader = /** @class */ (function (_super) {
|
||||
__extends(BrowserMultiFormatOneDReader, _super);
|
||||
/**
|
||||
* Creates an instance of BrowserBarcodeReader.
|
||||
* @param {Map<DecodeHintType, any>} hints?
|
||||
* @param options
|
||||
*/
|
||||
function BrowserMultiFormatOneDReader(hints, options) {
|
||||
return _super.call(this, new library_1.MultiFormatOneDReader(hints), hints, options) || this;
|
||||
}
|
||||
return BrowserMultiFormatOneDReader;
|
||||
}(BrowserCodeReader_1.BrowserCodeReader));
|
||||
exports.BrowserMultiFormatOneDReader = BrowserMultiFormatOneDReader;
|
||||
//# sourceMappingURL=BrowserMultiFormatOneDReader.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserMultiFormatOneDReader.js","sourceRoot":"","sources":["../../../src/readers/BrowserMultiFormatOneDReader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAAuE;AACvE,yDAAwD;AAGxD;;GAEG;AACH;IAAkD,gDAAiB;IACjE;;;;OAIG;IACH,sCAAmB,KAAgC,EAAE,OAAmC;eACtF,kBAAM,IAAI,+BAAqB,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC;IACzD,CAAC;IACH,mCAAC;AAAD,CAAC,AATD,CAAkD,qCAAiB,GASlE;AATY,oEAA4B"}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { BarcodeFormat, BinaryBitmap, DecodeHintType, MultiFormatReader, Result } from '@zxing/library';
|
||||
import { BrowserCodeReader } from './BrowserCodeReader';
|
||||
import { IBrowserCodeReaderOptions } from './IBrowserCodeReaderOptions';
|
||||
export declare class BrowserMultiFormatReader extends BrowserCodeReader {
|
||||
set possibleFormats(formats: BarcodeFormat[]);
|
||||
protected readonly reader: MultiFormatReader;
|
||||
constructor(hints?: Map<DecodeHintType, any>, options?: IBrowserCodeReaderOptions);
|
||||
/**
|
||||
* Overwrite decodeBitmap to call decodeWithState, which will pay
|
||||
* attention to the hints set in the constructor function
|
||||
*/
|
||||
decodeBitmap(binaryBitmap: BinaryBitmap): Result;
|
||||
/**
|
||||
* Allows to change hints in runtime.
|
||||
*/
|
||||
setHints(hints: Map<DecodeHintType, any>): void;
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserMultiFormatReader = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var BrowserCodeReader_1 = require("./BrowserCodeReader");
|
||||
var BrowserMultiFormatReader = /** @class */ (function (_super) {
|
||||
__extends(BrowserMultiFormatReader, _super);
|
||||
function BrowserMultiFormatReader(hints, options) {
|
||||
var _this = this;
|
||||
var reader = new library_1.MultiFormatReader();
|
||||
reader.setHints(hints);
|
||||
_this = _super.call(this, reader, hints, options) || this;
|
||||
_this.reader = reader;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(BrowserMultiFormatReader.prototype, "possibleFormats", {
|
||||
set: function (formats) {
|
||||
this.hints.set(library_1.DecodeHintType.POSSIBLE_FORMATS, formats);
|
||||
this.reader.setHints(this.hints);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* Overwrite decodeBitmap to call decodeWithState, which will pay
|
||||
* attention to the hints set in the constructor function
|
||||
*/
|
||||
BrowserMultiFormatReader.prototype.decodeBitmap = function (binaryBitmap) {
|
||||
return this.reader.decodeWithState(binaryBitmap);
|
||||
};
|
||||
/**
|
||||
* Allows to change hints in runtime.
|
||||
*/
|
||||
BrowserMultiFormatReader.prototype.setHints = function (hints) {
|
||||
this.hints = hints;
|
||||
this.reader.setHints(this.hints);
|
||||
};
|
||||
return BrowserMultiFormatReader;
|
||||
}(BrowserCodeReader_1.BrowserCodeReader));
|
||||
exports.BrowserMultiFormatReader = BrowserMultiFormatReader;
|
||||
//# sourceMappingURL=BrowserMultiFormatReader.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserMultiFormatReader.js","sourceRoot":"","sources":["../../../src/readers/BrowserMultiFormatReader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAMwB;AACxB,yDAAwD;AAGxD;IAA8C,4CAAiB;IAS7D,kCACE,KAAgC,EAChC,OAAmC;QAFrC,iBAQC;QAJC,IAAM,MAAM,GAAG,IAAI,2BAAiB,EAAE,CAAC;QACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,QAAA,kBAAM,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,SAAC;QAC9B,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACvB,CAAC;IAfD,sBAAI,qDAAe;aAAnB,UAAoB,OAAwB;YAC1C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,wBAAc,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;YACzD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;;;OAAA;IAcD;;;OAGG;IACI,+CAAY,GAAnB,UAAoB,YAA0B;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,2CAAQ,GAAf,UAAgB,KAA+B;QAC7C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IACH,+BAAC;AAAD,CAAC,AAlCD,CAA8C,qCAAiB,GAkC9D;AAlCY,4DAAwB"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { DecodeHintType } from '@zxing/library';
|
||||
import { BrowserCodeReader } from './BrowserCodeReader';
|
||||
import { IBrowserCodeReaderOptions } from './IBrowserCodeReaderOptions';
|
||||
/**
|
||||
* QR Code reader to use from browser.
|
||||
*/
|
||||
export declare class BrowserPDF417Reader extends BrowserCodeReader {
|
||||
/**
|
||||
* Creates an instance of BrowserPDF417Reader.
|
||||
*/
|
||||
constructor(hints?: Map<DecodeHintType, any>, options?: IBrowserCodeReaderOptions);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserPDF417Reader = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var BrowserCodeReader_1 = require("./BrowserCodeReader");
|
||||
/**
|
||||
* QR Code reader to use from browser.
|
||||
*/
|
||||
var BrowserPDF417Reader = /** @class */ (function (_super) {
|
||||
__extends(BrowserPDF417Reader, _super);
|
||||
/**
|
||||
* Creates an instance of BrowserPDF417Reader.
|
||||
*/
|
||||
function BrowserPDF417Reader(hints, options) {
|
||||
return _super.call(this, new library_1.PDF417Reader(), hints, options) || this;
|
||||
}
|
||||
return BrowserPDF417Reader;
|
||||
}(BrowserCodeReader_1.BrowserCodeReader));
|
||||
exports.BrowserPDF417Reader = BrowserPDF417Reader;
|
||||
//# sourceMappingURL=BrowserPDF417Reader.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserPDF417Reader.js","sourceRoot":"","sources":["../../../src/readers/BrowserPDF417Reader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAA8D;AAC9D,yDAAwD;AAGxD;;GAEG;AACH;IAAyC,uCAAiB;IACxD;;OAEG;IACH,6BACE,KAAgC,EAChC,OAAmC;eAEnC,kBAAM,IAAI,sBAAY,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC;IAC3C,CAAC;IACH,0BAAC;AAAD,CAAC,AAVD,CAAyC,qCAAiB,GAUzD;AAVY,kDAAmB"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { DecodeHintType } from '@zxing/library';
|
||||
import { BrowserCodeReader } from './BrowserCodeReader';
|
||||
import { IBrowserCodeReaderOptions } from './IBrowserCodeReaderOptions';
|
||||
/**
|
||||
* QR Code reader to use from browser.
|
||||
*/
|
||||
export declare class BrowserQRCodeReader extends BrowserCodeReader {
|
||||
/**
|
||||
* Creates an instance of BrowserQRCodeReader.
|
||||
*/
|
||||
constructor(hints?: Map<DecodeHintType, any>, options?: IBrowserCodeReaderOptions);
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserQRCodeReader = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var BrowserCodeReader_1 = require("./BrowserCodeReader");
|
||||
/**
|
||||
* QR Code reader to use from browser.
|
||||
*/
|
||||
var BrowserQRCodeReader = /** @class */ (function (_super) {
|
||||
__extends(BrowserQRCodeReader, _super);
|
||||
/**
|
||||
* Creates an instance of BrowserQRCodeReader.
|
||||
*/
|
||||
function BrowserQRCodeReader(hints, options) {
|
||||
return _super.call(this, new library_1.QRCodeReader(), hints, options) || this;
|
||||
}
|
||||
return BrowserQRCodeReader;
|
||||
}(BrowserCodeReader_1.BrowserCodeReader));
|
||||
exports.BrowserQRCodeReader = BrowserQRCodeReader;
|
||||
//# sourceMappingURL=BrowserQRCodeReader.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserQRCodeReader.js","sourceRoot":"","sources":["../../../src/readers/BrowserQRCodeReader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAA8D;AAC9D,yDAAwD;AAGxD;;GAEG;AACH;IAAyC,uCAAiB;IACxD;;OAEG;IACH,6BACE,KAAgC,EAChC,OAAmC;eAEnC,kBAAM,IAAI,sBAAY,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC;IAC3C,CAAC;IACH,0BAAC;AAAD,CAAC,AAVD,CAAyC,qCAAiB,GAUzD;AAVY,kDAAmB"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export interface IBrowserCodeReaderOptions {
|
||||
/** Delay time between subsequent successful decode results. */
|
||||
delayBetweenScanSuccess?: number;
|
||||
/** Delay time between decode attempts made by the scanner. */
|
||||
delayBetweenScanAttempts?: number;
|
||||
/** Timeout for waiting the video 'canplay' event. */
|
||||
tryPlayVideoTimeout?: number;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IBrowserCodeReaderOptions.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"IBrowserCodeReaderOptions.js","sourceRoot":"","sources":["../../../src/readers/IBrowserCodeReaderOptions.ts"],"names":[],"mappings":""}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import { EncodeHintType } from '@zxing/library';
|
||||
declare abstract class BrowserCodeSvgWriter {
|
||||
/**
|
||||
* Default quiet zone in pixels.
|
||||
*/
|
||||
private static readonly QUIET_ZONE_SIZE;
|
||||
/**
|
||||
* SVG markup NameSpace
|
||||
*/
|
||||
private static readonly SVG_NS;
|
||||
/**
|
||||
* A HTML container element for the image.
|
||||
*/
|
||||
private containerElement;
|
||||
/**
|
||||
* Constructs. 😉
|
||||
*/
|
||||
constructor(containerElement: string | HTMLElement);
|
||||
/**
|
||||
* Writes the QR code to a SVG and renders it in the container.
|
||||
*/
|
||||
write(contents: string, width: number, height: number, hints?: Map<EncodeHintType, any>): SVGSVGElement;
|
||||
/**
|
||||
* Creates a SVG element.
|
||||
*/
|
||||
protected createSVGElement(w: number, h: number): SVGSVGElement;
|
||||
/**
|
||||
* Creates a SVG rect.
|
||||
*/
|
||||
protected createSvgPathPlaceholderElement(w: number, h: number): SVGPathElement;
|
||||
/**
|
||||
* Creates a SVG rect.
|
||||
*/
|
||||
protected createSvgRectElement(x: number, y: number, w: number, h: number): SVGRectElement;
|
||||
/**
|
||||
* Encodes the content to a Barcode type.
|
||||
*/
|
||||
private encode;
|
||||
/**
|
||||
* Renders the SVG in the container.
|
||||
*
|
||||
* @note the input matrix uses 0 == white, 1 == black. The output matrix
|
||||
* uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
|
||||
*/
|
||||
private renderResult;
|
||||
}
|
||||
export { BrowserCodeSvgWriter };
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserCodeSvgWriter = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var svgNs = 'http://www.w3.org/2000/svg';
|
||||
/**/
|
||||
var BrowserCodeSvgWriter = /** @class */ (function () {
|
||||
/**
|
||||
* Constructs. 😉
|
||||
*/
|
||||
function BrowserCodeSvgWriter(containerElement) {
|
||||
if (typeof containerElement === 'string') {
|
||||
var container = document.getElementById(containerElement);
|
||||
if (!container) {
|
||||
throw new Error("Could not find a Container element with '".concat(containerElement, "'."));
|
||||
}
|
||||
this.containerElement = container;
|
||||
}
|
||||
else {
|
||||
this.containerElement = containerElement;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Writes the QR code to a SVG and renders it in the container.
|
||||
*/
|
||||
BrowserCodeSvgWriter.prototype.write = function (contents, width, height, hints) {
|
||||
if (contents.length === 0) {
|
||||
throw new library_1.IllegalArgumentException('Found empty contents');
|
||||
}
|
||||
if (width < 0 || height < 0) {
|
||||
throw new library_1.IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height);
|
||||
}
|
||||
var quietZone = hints && hints.get(library_1.EncodeHintType.MARGIN) !== undefined
|
||||
? Number.parseInt(hints.get(library_1.EncodeHintType.MARGIN).toString(), 10)
|
||||
: BrowserCodeSvgWriter.QUIET_ZONE_SIZE;
|
||||
var code = this.encode(hints, contents);
|
||||
return this.renderResult(code, width, height, quietZone);
|
||||
};
|
||||
/**
|
||||
* Creates a SVG element.
|
||||
*/
|
||||
BrowserCodeSvgWriter.prototype.createSVGElement = function (w, h) {
|
||||
var el = document.createElementNS(BrowserCodeSvgWriter.SVG_NS, 'svg');
|
||||
el.setAttributeNS(svgNs, 'width', h.toString());
|
||||
el.setAttributeNS(svgNs, 'height', w.toString());
|
||||
return el;
|
||||
};
|
||||
/**
|
||||
* Creates a SVG rect.
|
||||
*/
|
||||
BrowserCodeSvgWriter.prototype.createSvgPathPlaceholderElement = function (w, h) {
|
||||
var el = document.createElementNS(BrowserCodeSvgWriter.SVG_NS, 'path');
|
||||
el.setAttributeNS(svgNs, 'd', "M0 0h".concat(w, "v").concat(h, "H0z"));
|
||||
el.setAttributeNS(svgNs, 'fill', 'none');
|
||||
return el;
|
||||
};
|
||||
/**
|
||||
* Creates a SVG rect.
|
||||
*/
|
||||
BrowserCodeSvgWriter.prototype.createSvgRectElement = function (x, y, w, h) {
|
||||
var el = document.createElementNS(BrowserCodeSvgWriter.SVG_NS, 'rect');
|
||||
el.setAttributeNS(svgNs, 'x', x.toString());
|
||||
el.setAttributeNS(svgNs, 'y', y.toString());
|
||||
el.setAttributeNS(svgNs, 'height', w.toString());
|
||||
el.setAttributeNS(svgNs, 'width', h.toString());
|
||||
el.setAttributeNS(svgNs, 'fill', '#000000');
|
||||
return el;
|
||||
};
|
||||
/**
|
||||
* Encodes the content to a Barcode type.
|
||||
*/
|
||||
BrowserCodeSvgWriter.prototype.encode = function (hints, contents) {
|
||||
var errorCorrectionLevel = library_1.QRCodeDecoderErrorCorrectionLevel.L;
|
||||
if (hints && hints.get(library_1.EncodeHintType.ERROR_CORRECTION) !== undefined) {
|
||||
var correctionStr = hints.get(library_1.EncodeHintType.ERROR_CORRECTION).toString();
|
||||
errorCorrectionLevel = library_1.QRCodeDecoderErrorCorrectionLevel.fromString(correctionStr);
|
||||
}
|
||||
var code = library_1.QRCodeEncoder.encode(contents, errorCorrectionLevel, hints);
|
||||
return code;
|
||||
};
|
||||
/**
|
||||
* Renders the SVG in the container.
|
||||
*
|
||||
* @note the input matrix uses 0 == white, 1 == black. The output matrix
|
||||
* uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
|
||||
*/
|
||||
BrowserCodeSvgWriter.prototype.renderResult = function (code, width /*int*/, height /*int*/, quietZone /*int*/) {
|
||||
// if (this.format && format != this.format) {
|
||||
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format)
|
||||
// }
|
||||
var input = code.getMatrix();
|
||||
if (input === null) {
|
||||
throw new library_1.IllegalStateException();
|
||||
}
|
||||
var inputWidth = input.getWidth();
|
||||
var inputHeight = input.getHeight();
|
||||
var qrWidth = inputWidth + (quietZone * 2);
|
||||
var qrHeight = inputHeight + (quietZone * 2);
|
||||
var outputWidth = Math.max(width, qrWidth);
|
||||
var outputHeight = Math.max(height, qrHeight);
|
||||
var multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));
|
||||
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested
|
||||
// dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
|
||||
// If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
|
||||
// handle all the padding from 100x100 (the actual QR) up to 200x160.
|
||||
var leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);
|
||||
var topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);
|
||||
var svgElement = this.createSVGElement(outputWidth, outputHeight);
|
||||
var placeholder = this.createSvgPathPlaceholderElement(width, height);
|
||||
svgElement.appendChild(placeholder);
|
||||
this.containerElement.appendChild(svgElement);
|
||||
// 2D loop
|
||||
for (var inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
|
||||
// Write the contents of this row of the barcode
|
||||
for (var inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
|
||||
if (input.get(inputX, inputY) === 1) {
|
||||
var svgRectElement = this.createSvgRectElement(outputX, outputY, multiple, multiple);
|
||||
svgElement.appendChild(svgRectElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
return svgElement;
|
||||
};
|
||||
/**
|
||||
* Default quiet zone in pixels.
|
||||
*/
|
||||
BrowserCodeSvgWriter.QUIET_ZONE_SIZE = 4;
|
||||
/**
|
||||
* SVG markup NameSpace
|
||||
*/
|
||||
BrowserCodeSvgWriter.SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
return BrowserCodeSvgWriter;
|
||||
}());
|
||||
exports.BrowserCodeSvgWriter = BrowserCodeSvgWriter;
|
||||
//# sourceMappingURL=BrowserCodeSvgWriter.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserCodeSvgWriter.js","sourceRoot":"","sources":["../../../src/writers/BrowserCodeSvgWriter.ts"],"names":[],"mappings":";;;AAAA,0CAOwB;AAExB,IAAM,KAAK,GAAG,4BAA4B,CAAC;AAE3C,IAAI;AACJ;IAiBE;;OAEG;IACH,8BAAmB,gBAAsC;QACvD,IAAI,OAAO,gBAAgB,KAAK,QAAQ,EAAE;YACxC,IAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;YAC5D,IAAI,CAAC,SAAS,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,mDAA4C,gBAAgB,OAAI,CAAC,CAAC;aAAE;YAEtG,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;SACnC;aAAM;YACL,IA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AA,AAhLD,IAgLC;AAEQ,oDAAoB"}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import { EncodeHintType } from '@zxing/library';
|
||||
declare class BrowserQRCodeSvgWriter {
|
||||
private static readonly QUIET_ZONE_SIZE;
|
||||
/**
|
||||
* Writes and renders a QRCode SVG element.
|
||||
*
|
||||
* @param contents
|
||||
* @param width
|
||||
* @param height
|
||||
* @param hints
|
||||
*/
|
||||
write(contents: string, width: number, height: number, hints?: Map<EncodeHintType, any>): SVGSVGElement;
|
||||
/**
|
||||
* Renders the result and then appends it to the DOM.
|
||||
*/
|
||||
writeToDom(containerElement: string | HTMLElement, contents: string, width: number, height: number, hints?: Map<EncodeHintType, any>): void;
|
||||
/**
|
||||
* Note that the input matrix uses 0 == white, 1 == black.
|
||||
* The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
|
||||
*/
|
||||
private renderResult;
|
||||
/**
|
||||
* Creates a SVG element.
|
||||
*
|
||||
* @param w SVG's width attribute
|
||||
* @param h SVG's height attribute
|
||||
*/
|
||||
private createSVGElement;
|
||||
/**
|
||||
* Creates a SVG rect element.
|
||||
*
|
||||
* @param x Element's x coordinate
|
||||
* @param y Element's y coordinate
|
||||
* @param w Element's width attribute
|
||||
* @param h Element's height attribute
|
||||
*/
|
||||
private createSvgRectElement;
|
||||
}
|
||||
export { BrowserQRCodeSvgWriter };
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BrowserQRCodeSvgWriter = void 0;
|
||||
var library_1 = require("@zxing/library");
|
||||
var svgNs = 'http://www.w3.org/2000/svg';
|
||||
/**/
|
||||
var BrowserQRCodeSvgWriter = /** @class */ (function () {
|
||||
function BrowserQRCodeSvgWriter() {
|
||||
}
|
||||
/**
|
||||
* Writes and renders a QRCode SVG element.
|
||||
*
|
||||
* @param contents
|
||||
* @param width
|
||||
* @param height
|
||||
* @param hints
|
||||
*/
|
||||
BrowserQRCodeSvgWriter.prototype.write = function (contents, width, height, hints) {
|
||||
if (contents.length === 0) {
|
||||
throw new library_1.IllegalArgumentException('Found empty contents');
|
||||
}
|
||||
// if (format != BarcodeFormat.QR_CODE) {
|
||||
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format)
|
||||
// }
|
||||
if (width < 0 || height < 0) {
|
||||
throw new library_1.IllegalArgumentException('Requested dimensions are too small: ' + width + 'x' + height);
|
||||
}
|
||||
var errorCorrectionLevel = library_1.QRCodeDecoderErrorCorrectionLevel.L;
|
||||
var quietZone = BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE;
|
||||
if (hints) {
|
||||
if (undefined !== hints.get(library_1.EncodeHintType.ERROR_CORRECTION)) {
|
||||
var correctionStr = hints.get(library_1.EncodeHintType.ERROR_CORRECTION).toString();
|
||||
errorCorrectionLevel = library_1.QRCodeDecoderErrorCorrectionLevel.fromString(correctionStr);
|
||||
}
|
||||
if (undefined !== hints.get(library_1.EncodeHintType.MARGIN)) {
|
||||
quietZone = Number.parseInt(hints.get(library_1.EncodeHintType.MARGIN).toString(), 10);
|
||||
}
|
||||
}
|
||||
var code = library_1.QRCodeEncoder.encode(contents, errorCorrectionLevel, hints);
|
||||
return this.renderResult(code, width, height, quietZone);
|
||||
};
|
||||
/**
|
||||
* Renders the result and then appends it to the DOM.
|
||||
*/
|
||||
BrowserQRCodeSvgWriter.prototype.writeToDom = function (containerElement, contents, width, height, hints) {
|
||||
if (typeof containerElement === 'string') {
|
||||
var targetEl = document.querySelector(containerElement);
|
||||
if (!targetEl) {
|
||||
throw new Error('Could no find the target HTML element.');
|
||||
}
|
||||
containerElement = targetEl;
|
||||
}
|
||||
var svgElement = this.write(contents, width, height, hints);
|
||||
if (containerElement instanceof HTMLElement) {
|
||||
containerElement.appendChild(svgElement);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Note that the input matrix uses 0 == white, 1 == black.
|
||||
* The output matrix uses 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
|
||||
*/
|
||||
BrowserQRCodeSvgWriter.prototype.renderResult = function (code, width /*int*/, height /*int*/, quietZone /*int*/) {
|
||||
var input = code.getMatrix();
|
||||
if (input === null) {
|
||||
throw new library_1.IllegalStateException();
|
||||
}
|
||||
var inputWidth = input.getWidth();
|
||||
var inputHeight = input.getHeight();
|
||||
var qrWidth = inputWidth + (quietZone * 2);
|
||||
var qrHeight = inputHeight + (quietZone * 2);
|
||||
var outputWidth = Math.max(width, qrWidth);
|
||||
var outputHeight = Math.max(height, qrHeight);
|
||||
var multiple = Math.min(Math.floor(outputWidth / qrWidth), Math.floor(outputHeight / qrHeight));
|
||||
// Padding includes both the quiet zone and the extra white pixels to accommodate the requested
|
||||
// dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.
|
||||
// If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will
|
||||
// handle all the padding from 100x100 (the actual QR) up to 200x160.
|
||||
var leftPadding = Math.floor((outputWidth - (inputWidth * multiple)) / 2);
|
||||
var topPadding = Math.floor((outputHeight - (inputHeight * multiple)) / 2);
|
||||
var svgElement = this.createSVGElement(outputWidth, outputHeight);
|
||||
for (var inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
|
||||
// Write the contents of this row of the barcode
|
||||
for (var inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
|
||||
if (input.get(inputX, inputY) === 1) {
|
||||
var svgRectElement = this.createSvgRectElement(outputX, outputY, multiple, multiple);
|
||||
svgElement.appendChild(svgRectElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
return svgElement;
|
||||
};
|
||||
/**
|
||||
* Creates a SVG element.
|
||||
*
|
||||
* @param w SVG's width attribute
|
||||
* @param h SVG's height attribute
|
||||
*/
|
||||
BrowserQRCodeSvgWriter.prototype.createSVGElement = function (w, h) {
|
||||
var svgElement = document.createElementNS(svgNs, 'svg');
|
||||
var width = w.toString();
|
||||
var height = h.toString();
|
||||
svgElement.setAttribute('height', height);
|
||||
svgElement.setAttribute('width', width);
|
||||
svgElement.setAttribute('viewBox', "0 0 " + width + " " + height);
|
||||
return svgElement;
|
||||
};
|
||||
/**
|
||||
* Creates a SVG rect element.
|
||||
*
|
||||
* @param x Element's x coordinate
|
||||
* @param y Element's y coordinate
|
||||
* @param w Element's width attribute
|
||||
* @param h Element's height attribute
|
||||
*/
|
||||
BrowserQRCodeSvgWriter.prototype.createSvgRectElement = function (x, y, w, h) {
|
||||
var rect = document.createElementNS(svgNs, 'rect');
|
||||
rect.setAttribute('x', x.toString());
|
||||
rect.setAttribute('y', y.toString());
|
||||
rect.setAttribute('height', w.toString());
|
||||
rect.setAttribute('width', h.toString());
|
||||
rect.setAttribute('fill', '#000000');
|
||||
return rect;
|
||||
};
|
||||
BrowserQRCodeSvgWriter.QUIET_ZONE_SIZE = 4;
|
||||
return BrowserQRCodeSvgWriter;
|
||||
}());
|
||||
exports.BrowserQRCodeSvgWriter = BrowserQRCodeSvgWriter;
|
||||
//# sourceMappingURL=BrowserQRCodeSvgWriter.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BrowserQRCodeSvgWriter.js","sourceRoot":"","sources":["../../../src/writers/BrowserQRCodeSvgWriter.ts"],"names":[],"mappings":";;;AAAA,0CAOwB;AAExB,IAAM,KAAK,GAAG,4BAA4B,CAAC;AAE3C,IAAI;AACJ;IAAA;IAiKA,CAAC;IA7JC;;;;;;;OAOG;IACI,sCAAK,GAAZ,UACE,QAAgB,EAChB,KAAa,EACb,MAAc,EACd,KAAgC;QAGhC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,MAAM,IAAI,kCAAwB,CAAC,sBAAsB,CAAC,CAAC;SAC5D;QAED,yCAAyC;QACzC,qFAAqF;QACrF,IAAI;QAEJ,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE;YAC3B,MAAM,IAAI,kCAAwB,CAAC,sCAAsC,GAAG,KAA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