Add barcode-detector-api-polyfill dependency and update environment variable declarations in SvelteKit project
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m50s

This commit is contained in:
eewing
2026-02-17 14:58:53 -06:00
parent cff20a652a
commit 9022114c8d
2137 changed files with 201996 additions and 762 deletions
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=DecodeContinuouslyCallback.js.map
@@ -0,0 +1 @@
{"version":3,"file":"DecodeContinuouslyCallback.js","sourceRoot":"","sources":["../../../src/common/DecodeContinuouslyCallback.ts"],"names":[],"mappings":""}
@@ -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;
}
@@ -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
@@ -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,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1,4 @@
/**
* HTML elements that can be decoded.
*/
export declare type HTMLVisualMediaElement = HTMLVideoElement | HTMLImageElement;
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=HTMLVisualMediaElement.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"HTMLVisualMediaElement.js","sourceRoot":"","sources":["../../../src/common/HTMLVisualMediaElement.ts"],"names":[],"mappings":""}
+30
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IScannerControls.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"IScannerControls.js","sourceRoot":"","sources":["../../../src/common/IScannerControls.ts"],"names":[],"mappings":""}
+8
View File
@@ -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
View File
@@ -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
View File
@@ -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"}