first commit
This commit is contained in:
3
frontend/node_modules/@rc-component/qrcode/es/QRCodeCanvas.d.ts
generated
vendored
Normal file
3
frontend/node_modules/@rc-component/qrcode/es/QRCodeCanvas.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import React from 'react';
|
||||
declare const QRCodeCanvas: React.ForwardRefExoticComponent<import("./interface").QRProps & React.CanvasHTMLAttributes<HTMLCanvasElement> & React.RefAttributes<HTMLCanvasElement>>;
|
||||
export { QRCodeCanvas };
|
||||
134
frontend/node_modules/@rc-component/qrcode/es/QRCodeCanvas.js
generated
vendored
Normal file
134
frontend/node_modules/@rc-component/qrcode/es/QRCodeCanvas.js
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["value", "size", "level", "bgColor", "fgColor", "includeMargin", "minVersion", "marginSize", "style", "imageSettings", "boostLevel"];
|
||||
import React from 'react';
|
||||
import { useQRCode } from "./hooks/useQRCode";
|
||||
import { DEFAULT_BACKGROUND_COLOR, DEFAULT_FRONT_COLOR, DEFAULT_NEED_MARGIN, DEFAULT_LEVEL, DEFAULT_MINVERSION, DEFAULT_SIZE, isSupportPath2d, excavateModules, generatePath } from "./utils";
|
||||
var QRCodeCanvas = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var value = props.value,
|
||||
_props$size = props.size,
|
||||
size = _props$size === void 0 ? DEFAULT_SIZE : _props$size,
|
||||
_props$level = props.level,
|
||||
level = _props$level === void 0 ? DEFAULT_LEVEL : _props$level,
|
||||
_props$bgColor = props.bgColor,
|
||||
bgColor = _props$bgColor === void 0 ? DEFAULT_BACKGROUND_COLOR : _props$bgColor,
|
||||
_props$fgColor = props.fgColor,
|
||||
fgColor = _props$fgColor === void 0 ? DEFAULT_FRONT_COLOR : _props$fgColor,
|
||||
_props$includeMargin = props.includeMargin,
|
||||
includeMargin = _props$includeMargin === void 0 ? DEFAULT_NEED_MARGIN : _props$includeMargin,
|
||||
_props$minVersion = props.minVersion,
|
||||
minVersion = _props$minVersion === void 0 ? DEFAULT_MINVERSION : _props$minVersion,
|
||||
marginSize = props.marginSize,
|
||||
style = props.style,
|
||||
imageSettings = props.imageSettings,
|
||||
boostLevel = props.boostLevel,
|
||||
otherProps = _objectWithoutProperties(props, _excluded);
|
||||
var imgSrc = imageSettings === null || imageSettings === void 0 ? void 0 : imageSettings.src;
|
||||
var _canvas = React.useRef(null);
|
||||
var _image = React.useRef(null);
|
||||
var setCanvasRef = React.useCallback(function (node) {
|
||||
_canvas.current = node;
|
||||
if (typeof ref === 'function') {
|
||||
ref(node);
|
||||
} else if (ref) {
|
||||
ref.current = node;
|
||||
}
|
||||
}, [ref]);
|
||||
var _React$useState = React.useState(false),
|
||||
_React$useState2 = _slicedToArray(_React$useState, 2),
|
||||
setIsImageLoaded = _React$useState2[1];
|
||||
var _useQRCode = useQRCode({
|
||||
value: value,
|
||||
level: level,
|
||||
minVersion: minVersion,
|
||||
includeMargin: includeMargin,
|
||||
marginSize: marginSize,
|
||||
imageSettings: imageSettings,
|
||||
size: size,
|
||||
boostLevel: boostLevel
|
||||
}),
|
||||
margin = _useQRCode.margin,
|
||||
cells = _useQRCode.cells,
|
||||
numCells = _useQRCode.numCells,
|
||||
calculatedImageSettings = _useQRCode.calculatedImageSettings;
|
||||
React.useEffect(function () {
|
||||
if (_canvas.current) {
|
||||
var canvas = _canvas.current;
|
||||
var ctx = canvas.getContext('2d');
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
var cellsToDraw = cells;
|
||||
var image = _image.current;
|
||||
var haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
|
||||
if (haveImageToRender) {
|
||||
if (calculatedImageSettings.excavation != null) {
|
||||
cellsToDraw = excavateModules(cells, calculatedImageSettings.excavation);
|
||||
}
|
||||
}
|
||||
var pixelRatio = window.devicePixelRatio || 1;
|
||||
canvas.height = canvas.width = size * pixelRatio;
|
||||
var scale = size / numCells * pixelRatio;
|
||||
ctx.scale(scale, scale);
|
||||
ctx.fillStyle = bgColor;
|
||||
ctx.fillRect(0, 0, numCells, numCells);
|
||||
ctx.fillStyle = fgColor;
|
||||
if (isSupportPath2d) {
|
||||
ctx.fill(new Path2D(generatePath(cellsToDraw, margin)));
|
||||
} else {
|
||||
cells.forEach(function (row, rdx) {
|
||||
row.forEach(function (cell, cdx) {
|
||||
if (cell) {
|
||||
ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (calculatedImageSettings) {
|
||||
ctx.globalAlpha = calculatedImageSettings.opacity;
|
||||
}
|
||||
if (haveImageToRender) {
|
||||
ctx.drawImage(image, calculatedImageSettings.x + margin, calculatedImageSettings.y + margin, calculatedImageSettings.w, calculatedImageSettings.h);
|
||||
}
|
||||
}
|
||||
});
|
||||
React.useEffect(function () {
|
||||
setIsImageLoaded(false);
|
||||
}, [imgSrc]);
|
||||
var canvasStyle = _objectSpread({
|
||||
height: size,
|
||||
width: size
|
||||
}, style);
|
||||
var img = null;
|
||||
if (imgSrc != null) {
|
||||
img = /*#__PURE__*/React.createElement("img", {
|
||||
alt: "QR-Code",
|
||||
src: imgSrc,
|
||||
key: imgSrc,
|
||||
style: {
|
||||
display: 'none'
|
||||
},
|
||||
onLoad: function onLoad() {
|
||||
setIsImageLoaded(true);
|
||||
},
|
||||
ref: _image
|
||||
// when crossOrigin is not set, the image will be tainted
|
||||
// and the canvas cannot be exported to an image
|
||||
,
|
||||
crossOrigin: calculatedImageSettings === null || calculatedImageSettings === void 0 ? void 0 : calculatedImageSettings.crossOrigin
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("canvas", _extends({
|
||||
style: canvasStyle,
|
||||
height: size,
|
||||
width: size,
|
||||
ref: setCanvasRef,
|
||||
role: "img"
|
||||
}, otherProps)), img);
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
QRCodeCanvas.displayName = 'QRCodeCanvas';
|
||||
}
|
||||
export { QRCodeCanvas };
|
||||
3
frontend/node_modules/@rc-component/qrcode/es/QRCodeSVG.d.ts
generated
vendored
Normal file
3
frontend/node_modules/@rc-component/qrcode/es/QRCodeSVG.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import React from 'react';
|
||||
declare const QRCodeSVG: React.ForwardRefExoticComponent<import("./interface").QRProps & React.SVGAttributes<SVGSVGElement> & React.RefAttributes<SVGSVGElement>>;
|
||||
export { QRCodeSVG };
|
||||
80
frontend/node_modules/@rc-component/qrcode/es/QRCodeSVG.js
generated
vendored
Normal file
80
frontend/node_modules/@rc-component/qrcode/es/QRCodeSVG.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["value", "size", "level", "bgColor", "fgColor", "includeMargin", "minVersion", "title", "marginSize", "imageSettings", "boostLevel"];
|
||||
import React from 'react';
|
||||
import { DEFAULT_BACKGROUND_COLOR, DEFAULT_FRONT_COLOR, DEFAULT_NEED_MARGIN, DEFAULT_LEVEL, DEFAULT_MINVERSION, DEFAULT_SIZE, excavateModules, generatePath } from "./utils";
|
||||
import { useQRCode } from "./hooks/useQRCode";
|
||||
var QRCodeSVG = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
||||
var value = props.value,
|
||||
_props$size = props.size,
|
||||
size = _props$size === void 0 ? DEFAULT_SIZE : _props$size,
|
||||
_props$level = props.level,
|
||||
level = _props$level === void 0 ? DEFAULT_LEVEL : _props$level,
|
||||
_props$bgColor = props.bgColor,
|
||||
bgColor = _props$bgColor === void 0 ? DEFAULT_BACKGROUND_COLOR : _props$bgColor,
|
||||
_props$fgColor = props.fgColor,
|
||||
fgColor = _props$fgColor === void 0 ? DEFAULT_FRONT_COLOR : _props$fgColor,
|
||||
_props$includeMargin = props.includeMargin,
|
||||
includeMargin = _props$includeMargin === void 0 ? DEFAULT_NEED_MARGIN : _props$includeMargin,
|
||||
_props$minVersion = props.minVersion,
|
||||
minVersion = _props$minVersion === void 0 ? DEFAULT_MINVERSION : _props$minVersion,
|
||||
title = props.title,
|
||||
marginSize = props.marginSize,
|
||||
imageSettings = props.imageSettings,
|
||||
boostLevel = props.boostLevel,
|
||||
otherProps = _objectWithoutProperties(props, _excluded);
|
||||
var _useQRCode = useQRCode({
|
||||
value: value,
|
||||
level: level,
|
||||
minVersion: minVersion,
|
||||
includeMargin: includeMargin,
|
||||
marginSize: marginSize,
|
||||
imageSettings: imageSettings,
|
||||
size: size,
|
||||
boostLevel: boostLevel
|
||||
}),
|
||||
margin = _useQRCode.margin,
|
||||
cells = _useQRCode.cells,
|
||||
numCells = _useQRCode.numCells,
|
||||
calculatedImageSettings = _useQRCode.calculatedImageSettings;
|
||||
var cellsToDraw = cells;
|
||||
var image = null;
|
||||
if (imageSettings != null && calculatedImageSettings != null) {
|
||||
if (calculatedImageSettings.excavation != null) {
|
||||
cellsToDraw = excavateModules(cells, calculatedImageSettings.excavation);
|
||||
}
|
||||
image = /*#__PURE__*/React.createElement("image", {
|
||||
href: imageSettings.src,
|
||||
height: calculatedImageSettings.h,
|
||||
width: calculatedImageSettings.w,
|
||||
x: calculatedImageSettings.x + margin,
|
||||
y: calculatedImageSettings.y + margin,
|
||||
preserveAspectRatio: "none",
|
||||
opacity: calculatedImageSettings.opacity
|
||||
// when crossOrigin is not set, the image will be tainted
|
||||
// and the canvas cannot be exported to an image
|
||||
,
|
||||
crossOrigin: calculatedImageSettings.crossOrigin
|
||||
});
|
||||
}
|
||||
var fgPath = generatePath(cellsToDraw, margin);
|
||||
return /*#__PURE__*/React.createElement("svg", _extends({
|
||||
height: size,
|
||||
width: size,
|
||||
viewBox: "0 0 ".concat(numCells, " ").concat(numCells),
|
||||
ref: ref,
|
||||
role: "img"
|
||||
}, otherProps), !!title && /*#__PURE__*/React.createElement("title", null, title), /*#__PURE__*/React.createElement("path", {
|
||||
fill: bgColor,
|
||||
d: "M0,0 h".concat(numCells, "v").concat(numCells, "H0z"),
|
||||
shapeRendering: "crispEdges"
|
||||
}), /*#__PURE__*/React.createElement("path", {
|
||||
fill: fgColor,
|
||||
d: fgPath,
|
||||
shapeRendering: "crispEdges"
|
||||
}), image);
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
QRCodeSVG.displayName = 'QRCodeSVG';
|
||||
}
|
||||
export { QRCodeSVG };
|
||||
28
frontend/node_modules/@rc-component/qrcode/es/hooks/useQRCode.d.ts
generated
vendored
Normal file
28
frontend/node_modules/@rc-component/qrcode/es/hooks/useQRCode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { QrCode } from '../libs/qrcodegen';
|
||||
import type { ErrorCorrectionLevel, ImageSettings } from '../interface';
|
||||
interface Options {
|
||||
value: string | string[];
|
||||
level: ErrorCorrectionLevel;
|
||||
minVersion: number;
|
||||
includeMargin: boolean;
|
||||
marginSize?: number;
|
||||
imageSettings?: ImageSettings;
|
||||
size: number;
|
||||
boostLevel?: boolean;
|
||||
}
|
||||
export declare const useQRCode: (opt: Options) => {
|
||||
cells: boolean[][];
|
||||
margin: number;
|
||||
numCells: number;
|
||||
calculatedImageSettings: {
|
||||
x: number;
|
||||
y: number;
|
||||
h: number;
|
||||
w: number;
|
||||
excavation: import("../interface").Excavation;
|
||||
opacity: number;
|
||||
crossOrigin: import("../interface").CrossOrigin;
|
||||
};
|
||||
qrcode: QrCode;
|
||||
};
|
||||
export {};
|
||||
35
frontend/node_modules/@rc-component/qrcode/es/hooks/useQRCode.js
generated
vendored
Normal file
35
frontend/node_modules/@rc-component/qrcode/es/hooks/useQRCode.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import { QrCode, QrSegment } from "../libs/qrcodegen";
|
||||
import { ERROR_LEVEL_MAP, getImageSettings, getMarginSize } from "../utils";
|
||||
import React from 'react';
|
||||
export var useQRCode = function useQRCode(opt) {
|
||||
var value = opt.value,
|
||||
level = opt.level,
|
||||
minVersion = opt.minVersion,
|
||||
includeMargin = opt.includeMargin,
|
||||
marginSize = opt.marginSize,
|
||||
imageSettings = opt.imageSettings,
|
||||
size = opt.size,
|
||||
boostLevel = opt.boostLevel;
|
||||
var memoizedQrcode = React.useMemo(function () {
|
||||
var values = Array.isArray(value) ? value : [value];
|
||||
var segments = values.reduce(function (acc, val) {
|
||||
acc.push.apply(acc, _toConsumableArray(QrSegment.makeSegments(val)));
|
||||
return acc;
|
||||
}, []);
|
||||
return QrCode.encodeSegments(segments, ERROR_LEVEL_MAP[level], minVersion, undefined, undefined, boostLevel);
|
||||
}, [value, level, minVersion, boostLevel]);
|
||||
return React.useMemo(function () {
|
||||
var cs = memoizedQrcode.getModules();
|
||||
var mg = getMarginSize(includeMargin, marginSize);
|
||||
var ncs = cs.length + mg * 2;
|
||||
var cis = getImageSettings(cs, size, mg, imageSettings);
|
||||
return {
|
||||
cells: cs,
|
||||
margin: mg,
|
||||
numCells: ncs,
|
||||
calculatedImageSettings: cis,
|
||||
qrcode: memoizedQrcode
|
||||
};
|
||||
}, [memoizedQrcode, size, imageSettings, includeMargin, marginSize]);
|
||||
};
|
||||
4
frontend/node_modules/@rc-component/qrcode/es/index.d.ts
generated
vendored
Normal file
4
frontend/node_modules/@rc-component/qrcode/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export type * from './interface';
|
||||
export * from './utils';
|
||||
export * from './QRCodeCanvas';
|
||||
export * from './QRCodeSVG';
|
||||
3
frontend/node_modules/@rc-component/qrcode/es/index.js
generated
vendored
Normal file
3
frontend/node_modules/@rc-component/qrcode/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./utils";
|
||||
export * from "./QRCodeCanvas";
|
||||
export * from "./QRCodeSVG";
|
||||
131
frontend/node_modules/@rc-component/qrcode/es/interface.d.ts
generated
vendored
Normal file
131
frontend/node_modules/@rc-component/qrcode/es/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
import type React from 'react';
|
||||
import type { Ecc, QrCode } from './libs/qrcodegen';
|
||||
export type Modules = ReturnType<QrCode['getModules']>;
|
||||
export type Excavation = {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export type ErrorCorrectionLevel = 'L' | 'M' | 'Q' | 'H';
|
||||
export type CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined;
|
||||
export type ERROR_LEVEL_MAPPED_TYPE = {
|
||||
[index in ErrorCorrectionLevel]: Ecc;
|
||||
};
|
||||
export type ImageSettings = {
|
||||
/**
|
||||
* The URI of the embedded image.
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* The height, in pixels, of the image.
|
||||
*/
|
||||
height: number;
|
||||
/**
|
||||
* The width, in pixels, of the image.
|
||||
*/
|
||||
width: number;
|
||||
/**
|
||||
* Whether or not to "excavate" the modules around the embedded image. This
|
||||
* means that any modules the embedded image overlaps will use the background
|
||||
* color.
|
||||
*/
|
||||
excavate: boolean;
|
||||
/**
|
||||
* The horiztonal offset of the embedded image, starting from the top left corner.
|
||||
* Will center if not specified.
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* The vertical offset of the embedded image, starting from the top left corner.
|
||||
* Will center if not specified.
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* The opacity of the embedded image in the range of 0-1.
|
||||
* @defaultValue 1
|
||||
*/
|
||||
opacity?: number;
|
||||
/**
|
||||
* The cross-origin value to use when loading the image. This is used to
|
||||
* ensure compatibility with CORS, particularly when extracting image data
|
||||
* from QRCodeCanvas.
|
||||
* Note: `undefined` is treated differently than the seemingly equivalent
|
||||
* empty string. This is intended to align with HTML behavior where omitting
|
||||
* the attribute behaves differently than the empty string.
|
||||
*/
|
||||
crossOrigin?: CrossOrigin;
|
||||
};
|
||||
export type QRProps = {
|
||||
/**
|
||||
* The value to encode into the QR Code. An array of strings can be passed in
|
||||
* to represent multiple segments to further optimize the QR Code.
|
||||
*/
|
||||
value: string | string[];
|
||||
/**
|
||||
* If enabled, the Error Correction Level of the result may be higher than
|
||||
* the specified Error Correction Level option if it can be done without
|
||||
* increasing the version.
|
||||
* @defaultValue true
|
||||
*/
|
||||
boostLevel?: boolean;
|
||||
/**
|
||||
* The size, in pixels, to render the QR Code.
|
||||
* @defaultValue 128
|
||||
*/
|
||||
size?: number;
|
||||
/**
|
||||
* The Error Correction Level to use.
|
||||
* @see https://www.qrcode.com/en/about/error_correction.html
|
||||
* @defaultValue L
|
||||
*/
|
||||
level?: ErrorCorrectionLevel;
|
||||
/**
|
||||
* The background color used to render the QR Code.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
|
||||
* @defaultValue #FFFFFF
|
||||
*/
|
||||
bgColor?: string;
|
||||
/**
|
||||
* The foregtound color used to render the QR Code.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
|
||||
* @defaultValue #000000
|
||||
*/
|
||||
fgColor?: string;
|
||||
/**
|
||||
* The style to apply to the QR Code.
|
||||
*/
|
||||
style?: React.CSSProperties;
|
||||
/**
|
||||
* Whether or not a margin of 4 modules should be rendered as a part of the
|
||||
* QR Code.
|
||||
* @deprecated Use `marginSize` instead.
|
||||
* @defaultValue false
|
||||
*/
|
||||
includeMargin?: boolean;
|
||||
/**
|
||||
* The number of _modules_ to use for margin. The QR Code specification
|
||||
* requires `4`, however you can specify any number. Values will be turned to
|
||||
* integers with `Math.floor`. Overrides `includeMargin` when both are specified.
|
||||
* @defaultValue 0
|
||||
*/
|
||||
marginSize?: number;
|
||||
/**
|
||||
* The settings for the embedded image.
|
||||
*/
|
||||
imageSettings?: ImageSettings;
|
||||
/**
|
||||
* The title to assign to the QR Code. Used for accessibility reasons.
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* The minimum version used when encoding the QR Code. Valid values are 1-40
|
||||
* with higher values resulting in more complex QR Codes. The optimal
|
||||
* (lowest) version is determined for the `value` provided, using `minVersion`
|
||||
* as the lower bound.
|
||||
* @defaultValue 1
|
||||
*/
|
||||
minVersion?: number;
|
||||
};
|
||||
export type QRPropsCanvas = QRProps & React.CanvasHTMLAttributes<HTMLCanvasElement>;
|
||||
export type QRPropsSVG = QRProps & React.SVGAttributes<SVGSVGElement>;
|
||||
1
frontend/node_modules/@rc-component/qrcode/es/interface.js
generated
vendored
Normal file
1
frontend/node_modules/@rc-component/qrcode/es/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
80
frontend/node_modules/@rc-component/qrcode/es/libs/qrcodegen.d.ts
generated
vendored
Normal file
80
frontend/node_modules/@rc-component/qrcode/es/libs/qrcodegen.d.ts
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
export declare class Mode {
|
||||
static readonly NUMERIC: Mode;
|
||||
static readonly ALPHANUMERIC: Mode;
|
||||
static readonly BYTE: Mode;
|
||||
static readonly KANJI: Mode;
|
||||
static readonly ECI: Mode;
|
||||
modeBits: number;
|
||||
private numBitsCharCount;
|
||||
private constructor();
|
||||
numCharCountBits(ver: number): number;
|
||||
}
|
||||
export declare class Ecc {
|
||||
static readonly LOW: Ecc;
|
||||
static readonly MEDIUM: Ecc;
|
||||
static readonly QUARTILE: Ecc;
|
||||
static readonly HIGH: Ecc;
|
||||
ordinal: number;
|
||||
formatBits: number;
|
||||
private constructor();
|
||||
}
|
||||
export declare class QrSegment {
|
||||
static makeBytes(data: Readonly<number[]>): QrSegment;
|
||||
static makeNumeric(digits: string): QrSegment;
|
||||
static makeAlphanumeric(text: string): QrSegment;
|
||||
static makeSegments(text: string): QrSegment[];
|
||||
static makeEci(assignVal: number): QrSegment;
|
||||
static isNumeric(text: string): boolean;
|
||||
static isAlphanumeric(text: string): boolean;
|
||||
mode: Mode;
|
||||
numChars: number;
|
||||
private bitData;
|
||||
constructor(mode: Mode, numChars: number, bitData: number[]);
|
||||
getData(): number[];
|
||||
static getTotalBits(segs: Readonly<QrSegment[]>, version: number): number;
|
||||
private static toUtf8ByteArray;
|
||||
private static readonly NUMERIC_REGEX;
|
||||
private static readonly ALPHANUMERIC_REGEX;
|
||||
private static readonly ALPHANUMERIC_CHARSET;
|
||||
}
|
||||
export declare class QrCode {
|
||||
static encodeText(text: string, ecl: Ecc): QrCode;
|
||||
static encodeBinary(data: Readonly<number[]>, ecl: Ecc): QrCode;
|
||||
static encodeSegments(segs: Readonly<QrSegment[]>, oriEcl: Ecc, minVersion?: number, maxVersion?: number, mask?: number, boostEcl?: boolean): QrCode;
|
||||
readonly size: number;
|
||||
readonly mask: number;
|
||||
private readonly modules;
|
||||
private readonly isFunction;
|
||||
version: number;
|
||||
errorCorrectionLevel: Ecc;
|
||||
constructor(version: number, errorCorrectionLevel: Ecc, dataCodewords: Readonly<number[]>, oriMsk: number);
|
||||
getModule(x: number, y: number): boolean;
|
||||
getModules(): boolean[][];
|
||||
private drawFunctionPatterns;
|
||||
private drawFormatBits;
|
||||
private drawVersion;
|
||||
private drawFinderPattern;
|
||||
private drawAlignmentPattern;
|
||||
private setFunctionModule;
|
||||
private addEccAndInterleave;
|
||||
private drawCodewords;
|
||||
private applyMask;
|
||||
private getPenaltyScore;
|
||||
private getAlignmentPatternPositions;
|
||||
private static getNumRawDataModules;
|
||||
private static getNumDataCodewords;
|
||||
private static reedSolomonComputeDivisor;
|
||||
private static reedSolomonComputeRemainder;
|
||||
private static reedSolomonMultiply;
|
||||
private finderPenaltyCountPatterns;
|
||||
private finderPenaltyTerminateAndCount;
|
||||
private finderPenaltyAddHistory;
|
||||
static readonly MIN_VERSION: number;
|
||||
static readonly MAX_VERSION: number;
|
||||
private static readonly PENALTY_N1;
|
||||
private static readonly PENALTY_N2;
|
||||
private static readonly PENALTY_N3;
|
||||
private static readonly PENALTY_N4;
|
||||
private static readonly ECC_CODEWORDS_PER_BLOCK;
|
||||
private static readonly NUM_ERROR_CORRECTION_BLOCKS;
|
||||
}
|
||||
1116
frontend/node_modules/@rc-component/qrcode/es/libs/qrcodegen.js
generated
vendored
Normal file
1116
frontend/node_modules/@rc-component/qrcode/es/libs/qrcodegen.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
53
frontend/node_modules/@rc-component/qrcode/es/utils.d.ts
generated
vendored
Normal file
53
frontend/node_modules/@rc-component/qrcode/es/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import type { CrossOrigin, ERROR_LEVEL_MAPPED_TYPE, ErrorCorrectionLevel, Excavation, ImageSettings } from './interface';
|
||||
export declare const ERROR_LEVEL_MAP: ERROR_LEVEL_MAPPED_TYPE;
|
||||
export declare const DEFAULT_SIZE = 128;
|
||||
export declare const DEFAULT_LEVEL: ErrorCorrectionLevel;
|
||||
export declare const DEFAULT_BACKGROUND_COLOR = "#FFFFFF";
|
||||
export declare const DEFAULT_FRONT_COLOR = "#000000";
|
||||
export declare const DEFAULT_NEED_MARGIN = false;
|
||||
export declare const DEFAULT_MINVERSION = 1;
|
||||
export declare const SPEC_MARGIN_SIZE = 4;
|
||||
export declare const DEFAULT_MARGIN_SIZE = 0;
|
||||
export declare const DEFAULT_IMG_SCALE = 0.1;
|
||||
/**
|
||||
* Generate a path string from modules
|
||||
* @param modules
|
||||
* @param margin
|
||||
* @returns
|
||||
*/
|
||||
export declare const generatePath: (modules: boolean[][], margin?: number) => string;
|
||||
/**
|
||||
* Excavate modules
|
||||
* @param modules
|
||||
* @param excavation
|
||||
* @returns
|
||||
*/
|
||||
export declare const excavateModules: (modules: boolean[][], excavation: Excavation) => boolean[][];
|
||||
/**
|
||||
* Get image settings
|
||||
* @param cells The modules of the QR code
|
||||
* @param size The size of the QR code
|
||||
* @param margin
|
||||
* @param imageSettings
|
||||
* @returns
|
||||
*/
|
||||
export declare const getImageSettings: (cells: boolean[][], size: number, margin: number, imageSettings?: ImageSettings) => {
|
||||
x: number;
|
||||
y: number;
|
||||
h: number;
|
||||
w: number;
|
||||
excavation: Excavation | null;
|
||||
opacity: number;
|
||||
crossOrigin: CrossOrigin;
|
||||
};
|
||||
/**
|
||||
* Get margin size
|
||||
* @param needMargin Whether need margin
|
||||
* @param marginSize Custom margin size
|
||||
* @returns
|
||||
*/
|
||||
export declare const getMarginSize: (needMargin: boolean, marginSize?: number) => number;
|
||||
/**
|
||||
* Check if Path2D is supported
|
||||
*/
|
||||
export declare const isSupportPath2d: boolean;
|
||||
152
frontend/node_modules/@rc-component/qrcode/es/utils.js
generated
vendored
Normal file
152
frontend/node_modules/@rc-component/qrcode/es/utils.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
// Part logic is from `qrcode.react`. (ISC License)
|
||||
// https://github.com/zpao/qrcode.react
|
||||
|
||||
// ==========================================================
|
||||
|
||||
import { Ecc } from "./libs/qrcodegen";
|
||||
|
||||
// =================== ERROR_LEVEL ==========================
|
||||
export var ERROR_LEVEL_MAP = {
|
||||
L: Ecc.LOW,
|
||||
M: Ecc.MEDIUM,
|
||||
Q: Ecc.QUARTILE,
|
||||
H: Ecc.HIGH
|
||||
};
|
||||
|
||||
// =================== DEFAULT_VALUE ==========================
|
||||
export var DEFAULT_SIZE = 128;
|
||||
export var DEFAULT_LEVEL = 'L';
|
||||
export var DEFAULT_BACKGROUND_COLOR = '#FFFFFF';
|
||||
export var DEFAULT_FRONT_COLOR = '#000000';
|
||||
export var DEFAULT_NEED_MARGIN = false;
|
||||
export var DEFAULT_MINVERSION = 1;
|
||||
export var SPEC_MARGIN_SIZE = 4;
|
||||
export var DEFAULT_MARGIN_SIZE = 0;
|
||||
export var DEFAULT_IMG_SCALE = 0.1;
|
||||
|
||||
// =================== UTILS ==========================
|
||||
/**
|
||||
* Generate a path string from modules
|
||||
* @param modules
|
||||
* @param margin
|
||||
* @returns
|
||||
*/
|
||||
export var generatePath = function generatePath(modules) {
|
||||
var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
||||
var ops = [];
|
||||
modules.forEach(function (row, y) {
|
||||
var start = null;
|
||||
row.forEach(function (cell, x) {
|
||||
if (!cell && start !== null) {
|
||||
ops.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
|
||||
start = null;
|
||||
return;
|
||||
}
|
||||
if (x === row.length - 1) {
|
||||
if (!cell) {
|
||||
return;
|
||||
}
|
||||
if (start === null) {
|
||||
ops.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
|
||||
} else {
|
||||
ops.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (cell && start === null) {
|
||||
start = x;
|
||||
}
|
||||
});
|
||||
});
|
||||
return ops.join('');
|
||||
};
|
||||
|
||||
/**
|
||||
* Excavate modules
|
||||
* @param modules
|
||||
* @param excavation
|
||||
* @returns
|
||||
*/
|
||||
export var excavateModules = function excavateModules(modules, excavation) {
|
||||
return modules.slice().map(function (row, y) {
|
||||
if (y < excavation.y || y >= excavation.y + excavation.h) {
|
||||
return row;
|
||||
}
|
||||
return row.map(function (cell, x) {
|
||||
if (x < excavation.x || x >= excavation.x + excavation.w) {
|
||||
return cell;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get image settings
|
||||
* @param cells The modules of the QR code
|
||||
* @param size The size of the QR code
|
||||
* @param margin
|
||||
* @param imageSettings
|
||||
* @returns
|
||||
*/
|
||||
export var getImageSettings = function getImageSettings(cells, size, margin, imageSettings) {
|
||||
if (imageSettings == null) {
|
||||
return null;
|
||||
}
|
||||
var numCells = cells.length + margin * 2;
|
||||
var defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);
|
||||
var scale = numCells / size;
|
||||
var w = (imageSettings.width || defaultSize) * scale;
|
||||
var h = (imageSettings.height || defaultSize) * scale;
|
||||
var x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;
|
||||
var y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;
|
||||
var opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;
|
||||
var excavation = null;
|
||||
if (imageSettings.excavate) {
|
||||
var floorX = Math.floor(x);
|
||||
var floorY = Math.floor(y);
|
||||
var ceilW = Math.ceil(w + x - floorX);
|
||||
var ceilH = Math.ceil(h + y - floorY);
|
||||
excavation = {
|
||||
x: floorX,
|
||||
y: floorY,
|
||||
w: ceilW,
|
||||
h: ceilH
|
||||
};
|
||||
}
|
||||
var crossOrigin = imageSettings.crossOrigin;
|
||||
return {
|
||||
x: x,
|
||||
y: y,
|
||||
h: h,
|
||||
w: w,
|
||||
excavation: excavation,
|
||||
opacity: opacity,
|
||||
crossOrigin: crossOrigin
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Get margin size
|
||||
* @param needMargin Whether need margin
|
||||
* @param marginSize Custom margin size
|
||||
* @returns
|
||||
*/
|
||||
export var getMarginSize = function getMarginSize(needMargin, marginSize) {
|
||||
if (marginSize != null) {
|
||||
return Math.max(Math.floor(marginSize), 0);
|
||||
}
|
||||
return needMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if Path2D is supported
|
||||
*/
|
||||
export var isSupportPath2d = function () {
|
||||
try {
|
||||
new Path2D().addPath(new Path2D());
|
||||
} catch (_unused) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
Reference in New Issue
Block a user