First commit
This commit is contained in:
3
node_modules/swissqrbill/lib/cjs/package.json
generated
vendored
Normal file
3
node_modules/swissqrbill/lib/cjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
8
node_modules/swissqrbill/lib/cjs/pdf/index.cjs
generated
vendored
Normal file
8
node_modules/swissqrbill/lib/cjs/pdf/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const swissqrbill = require("./swissqrbill.cjs");
|
||||
const swissqrcode = require("./swissqrcode.cjs");
|
||||
const table = require("./table.cjs");
|
||||
exports.SwissQRBill = swissqrbill.SwissQRBill;
|
||||
exports.SwissQRCode = swissqrcode.SwissQRCode;
|
||||
exports.Table = table.Table;
|
||||
3
node_modules/swissqrbill/lib/cjs/pdf/index.d.ts
generated
vendored
Normal file
3
node_modules/swissqrbill/lib/cjs/pdf/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './swissqrbill.js';
|
||||
export * from './swissqrcode.js';
|
||||
export * from './table.js';
|
||||
395
node_modules/swissqrbill/lib/cjs/pdf/swissqrbill.cjs
generated
vendored
Normal file
395
node_modules/swissqrbill/lib/cjs/pdf/swissqrbill.cjs
generated
vendored
Normal file
@@ -0,0 +1,395 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const swissqrcode = require("./swissqrcode.cjs");
|
||||
const cleaner = require("../shared/cleaner.cjs");
|
||||
const translations = require("../shared/translations.cjs");
|
||||
const validator = require("../shared/validator.cjs");
|
||||
const utils = require("../shared/utils.cjs");
|
||||
const _SwissQRBill = class _SwissQRBill {
|
||||
/**
|
||||
* Creates a new SwissQRBill instance.
|
||||
*
|
||||
* @param data The data to be used for the QR Bill.
|
||||
* @param options Options to define how the QR Bill should be rendered.
|
||||
* @throws { ValidationError } Throws an error if the data is invalid.
|
||||
*/
|
||||
constructor(data, options) {
|
||||
this.scissors = true;
|
||||
this.separate = false;
|
||||
this.outlines = true;
|
||||
this.language = "DE";
|
||||
this.font = "Helvetica";
|
||||
this._x = 0;
|
||||
this._y = 0;
|
||||
this.data = cleaner.cleanData(data);
|
||||
validator.validateData(this.data);
|
||||
this.language = (options == null ? void 0 : options.language) !== void 0 ? options.language : this.language;
|
||||
this.outlines = (options == null ? void 0 : options.outlines) !== void 0 ? options.outlines : this.outlines;
|
||||
this.font = (options == null ? void 0 : options.fontName) !== void 0 ? options.fontName : this.font;
|
||||
if ((options == null ? void 0 : options.scissors) !== void 0) {
|
||||
this.scissors = options.scissors;
|
||||
this.separate = !options.scissors;
|
||||
}
|
||||
if ((options == null ? void 0 : options.separate) !== void 0) {
|
||||
this.separate = options.separate;
|
||||
this.scissors = !options.separate;
|
||||
}
|
||||
if ((options == null ? void 0 : options.scissors) === false && (options == null ? void 0 : options.separate) === false) {
|
||||
this.separate = false;
|
||||
this.scissors = false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Attaches the QR-Bill to a PDFKit document instance. It will create a new page with the size of the QR-Slip if not
|
||||
* enough space is left on the current page.
|
||||
*
|
||||
* @param doc The PDFKit instance.
|
||||
* @param x The horizontal position in points where the QR Bill will be placed.
|
||||
* @param y The vertical position in points where the QR Bill will be placed.
|
||||
*/
|
||||
attachTo(doc, x = 0, y = ((_a) => (_a = doc.page) == null ? void 0 : _a.height)() ? ((_b) => (_b = doc.page) == null ? void 0 : _b.height)() - utils.mm2pt(105) : 0) {
|
||||
if (!_SwissQRBill.isSpaceSufficient(doc, x, y)) {
|
||||
doc.addPage({
|
||||
margin: 0,
|
||||
size: [_SwissQRBill.width, _SwissQRBill.height]
|
||||
});
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this.render(doc);
|
||||
}
|
||||
/**
|
||||
* Checks whether there is enough space on the current page to add the QR Bill.
|
||||
*
|
||||
* @param doc The PDFKit document instance.
|
||||
* @param x The horizontal position where the QR Bill will be placed.
|
||||
* @param y The vertical position where the QR Bill will be placed.
|
||||
* @returns `true` if there is enough space, otherwise `false`.
|
||||
*/
|
||||
static isSpaceSufficient(doc, x = 0, y = ((_c) => (_c = doc.page) == null ? void 0 : _c.height)() ? ((_d) => (_d = doc.page) == null ? void 0 : _d.height)() - _SwissQRBill.height : 0) {
|
||||
if (!doc.page) {
|
||||
return false;
|
||||
}
|
||||
return Math.round(x + _SwissQRBill.width) <= Math.round(doc.page.width) && Math.round(doc.y + _SwissQRBill.height) <= Math.round(doc.page.height) && Math.round(y + _SwissQRBill.height) <= Math.round(doc.page.height);
|
||||
}
|
||||
x(millimeters = 0) {
|
||||
return this._x + utils.mm2pt(millimeters);
|
||||
}
|
||||
y(millimeters = 0) {
|
||||
return this._y + utils.mm2pt(millimeters);
|
||||
}
|
||||
render(doc) {
|
||||
if (this.outlines) {
|
||||
if (doc.page.height > utils.mm2pt(105)) {
|
||||
doc.moveTo(this.x(), this.y()).lineTo(this.x(210), this.y()).lineWidth(0.75).strokeOpacity(1).dash(1, { size: 1 }).strokeColor("black").stroke();
|
||||
}
|
||||
doc.moveTo(this.x(62), this.y()).lineTo(this.x(62), this.y(105)).lineWidth(0.75).strokeOpacity(1).dash(1, { size: 1 }).strokeColor("black").stroke();
|
||||
}
|
||||
if (this.scissors) {
|
||||
const scissorsTop = "4.545 -1.803 m 4.06 -2.388 3.185 -2.368 2.531 -2.116 c -1.575 -0.577 l -2.769 -1.23 -3.949 -1.043 -3.949 -1.361 c -3.949 -1.61 -3.721 -1.555 -3.755 -2.203 c -3.788 -2.825 -4.437 -3.285 -5.05 -3.244 c -5.664 -3.248 -6.3 -2.777 -6.305 -2.129 c -6.351 -1.476 -5.801 -0.869 -5.152 -0.826 c -4.391 -0.713 -3.043 -1.174 -2.411 -0.041 c -2.882 0.828 -3.718 0.831 -4.474 0.787 c -5.101 0.751 -5.855 0.931 -6.154 1.547 c -6.443 2.138 -6.16 2.979 -5.496 3.16 c -4.826 3.406 -3.906 3.095 -3.746 2.325 c -3.623 1.731 -4.044 1.452 -3.882 1.236 c -3.76 1.073 -2.987 1.168 -1.608 0.549 c 2.838 2.117 l 3.4 2.273 4.087 2.268 4.584 1.716 c -0.026 -0.027 l 4.545 -1.803 l h -4.609 -2.753 m -3.962 -2.392 -4.015 -1.411 -4.687 -1.221 c -5.295 -1.009 -6.073 -1.6 -5.879 -2.26 c -5.765 -2.801 -5.052 -3 -4.609 -2.753 c h -4.581 1.256 m -3.906 1.505 -4.02 2.648 -4.707 2.802 c -5.163 2.96 -5.814 2.733 -5.86 2.196 c -5.949 1.543 -5.182 0.954 -4.581 1.256 c h";
|
||||
const scissorsCenter = " 1.803 4.545 m 2.388 4.06 2.368 3.185 2.116 2.531 c 0.577 -1.575 l 1.23 -2.769 1.043 -3.949 1.361 -3.949 c 1.61 -3.949 1.555 -3.721 2.203 -3.755 c 2.825 -3.788 3.285 -4.437 3.244 -5.05 c 3.248 -5.664 2.777 -6.3 2.129 -6.305 c 1.476 -6.351 0.869 -5.801 0.826 -5.152 c 0.713 -4.391 1.174 -3.043 0.041 -2.411 c -0.828 -2.882 -0.831 -3.718 -0.787 -4.474 c -0.751 -5.101 -0.931 -5.855 -1.547 -6.154 c -2.138 -6.443 -2.979 -6.16 -3.16 -5.496 c -3.406 -4.826 -3.095 -3.906 -2.325 -3.746 c -1.731 -3.623 -1.452 -4.044 -1.236 -3.882 c -1.073 -3.76 -1.168 -2.987 -0.549 -1.608 c -2.117 2.838 l -2.273 3.4 -2.268 4.087 -1.716 4.584 c 0.027 -0.026 l 1.803 4.545 l h 2.753 -4.609 m 2.392 -3.962 1.411 -4.015 1.221 -4.687 c 1.009 -5.295 1.6 -6.073 2.26 -5.879 c 2.801 -5.765 3 -5.052 2.753 -4.609 c h -1.256 -4.581 m -1.505 -3.906 -2.648 -4.02 -2.802 -4.707 c -2.96 -5.163 -2.733 -5.814 -2.196 -5.86 c -1.543 -5.949 -0.954 -5.182 -1.256 -4.581 c h";
|
||||
if (doc.page.height > utils.mm2pt(105)) {
|
||||
doc.save();
|
||||
doc.translate(this.x(105), this.y());
|
||||
doc.addContent(scissorsTop).fillColor("black").fill();
|
||||
doc.restore();
|
||||
}
|
||||
doc.save();
|
||||
doc.translate(this.x(62), this.y() + 30);
|
||||
doc.addContent(scissorsCenter).fillColor("black").fill();
|
||||
doc.restore();
|
||||
}
|
||||
if (this.separate) {
|
||||
if (doc.page.height > utils.mm2pt(105)) {
|
||||
doc.fontSize(11);
|
||||
doc.font(this.font);
|
||||
doc.text(translations.translations[this.language].separate, 0, this.y() - 12, {
|
||||
align: "center",
|
||||
width: utils.mm2pt(210)
|
||||
});
|
||||
}
|
||||
}
|
||||
doc.fontSize(11);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].receipt, this.x(5), this.y(5), {
|
||||
align: "left",
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
doc.fontSize(6);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].account, this.x(5), this.y(12), {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
doc.fontSize(8);
|
||||
doc.font(this.font);
|
||||
doc.text(`${utils.formatIBAN(this.data.creditor.account)}
|
||||
${this.formatAddress(this.data.creditor)}`, {
|
||||
lineGap: -0.5,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
doc.fontSize(9);
|
||||
doc.moveDown();
|
||||
if (this.data.reference !== void 0) {
|
||||
doc.fontSize(6);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].reference, {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
doc.fontSize(8);
|
||||
doc.font(this.font);
|
||||
doc.text(utils.formatReference(this.data.reference), {
|
||||
lineGap: -0.5,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
doc.fontSize(9);
|
||||
doc.moveDown();
|
||||
}
|
||||
if (this.data.debtor !== void 0) {
|
||||
doc.fontSize(6);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].payableBy, {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
doc.fontSize(8);
|
||||
doc.font(this.font);
|
||||
doc.text(this.formatAddress(this.data.debtor), {
|
||||
lineGap: -0.5,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
} else {
|
||||
doc.fontSize(6);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].payableByName, {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
this.addRectangle(doc, 5, utils.pt2mm(doc.y - this.y()), 52, 20);
|
||||
}
|
||||
doc.fontSize(6);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].currency, this.x(5), this.y(68), {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(15)
|
||||
});
|
||||
const amountXPosition = this.data.amount === void 0 ? 18 : 27;
|
||||
doc.text(translations.translations[this.language].amount, this.x(amountXPosition), this.y(68), {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(52 - amountXPosition)
|
||||
});
|
||||
doc.fontSize(8);
|
||||
doc.font(this.font);
|
||||
doc.text(this.data.currency, this.x(5), this.y(71), {
|
||||
lineGap: -0.5,
|
||||
width: utils.mm2pt(15)
|
||||
});
|
||||
if (this.data.amount !== void 0) {
|
||||
doc.text(utils.formatAmount(this.data.amount), this.x(amountXPosition), this.y(71), {
|
||||
lineGap: -0.5,
|
||||
width: utils.mm2pt(52 - amountXPosition)
|
||||
});
|
||||
} else {
|
||||
this.addRectangle(doc, 27, 68, 30, 10);
|
||||
}
|
||||
doc.fontSize(6);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].acceptancePoint, this.x(5), this.y(82), {
|
||||
align: "right",
|
||||
height: utils.mm2pt(18),
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(52)
|
||||
});
|
||||
doc.fontSize(11);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].paymentPart, this.x(67), this.y(5), {
|
||||
align: "left",
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(51)
|
||||
});
|
||||
const swissQRCode = new swissqrcode.SwissQRCode(this.data);
|
||||
swissQRCode.attachTo(doc, this.x(67), this.y(17));
|
||||
doc.fontSize(8);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].currency, this.x(67), this.y(68), {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(15)
|
||||
});
|
||||
doc.text(translations.translations[this.language].amount, this.x(89), this.y(68), {
|
||||
width: utils.mm2pt(29)
|
||||
});
|
||||
doc.fontSize(10);
|
||||
doc.font(this.font);
|
||||
doc.text(this.data.currency, this.x(67), this.y(72), {
|
||||
lineGap: -0.5,
|
||||
width: utils.mm2pt(15)
|
||||
});
|
||||
if (this.data.amount !== void 0) {
|
||||
doc.text(utils.formatAmount(this.data.amount), this.x(89), this.y(72), {
|
||||
lineGap: -0.5,
|
||||
width: utils.mm2pt(29)
|
||||
});
|
||||
} else {
|
||||
this.addRectangle(doc, 78, 72, 40, 15);
|
||||
}
|
||||
if (this.data.av1 !== void 0) {
|
||||
const [scheme, data] = this.data.av1.split(/(\/.+)/);
|
||||
doc.fontSize(7);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(scheme, this.x(67), this.y(90), {
|
||||
continued: true,
|
||||
height: utils.mm2pt(3),
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(138)
|
||||
});
|
||||
doc.font(this.font);
|
||||
doc.text(this.data.av1.length > 90 ? `${data.substring(0, 87)}...` : data, {
|
||||
continued: false
|
||||
});
|
||||
}
|
||||
if (this.data.av2 !== void 0) {
|
||||
const [scheme, data] = this.data.av2.split(/(\/.+)/);
|
||||
doc.fontSize(7);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(scheme, this.x(67), this.y(93), {
|
||||
continued: true,
|
||||
height: utils.mm2pt(3),
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(138)
|
||||
});
|
||||
doc.font(this.font);
|
||||
doc.text(this.data.av2.length > 90 ? `${data.substring(0, 87)}...` : data, {
|
||||
lineGap: -0.5
|
||||
});
|
||||
}
|
||||
doc.fontSize(8);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].account, this.x(118), this.y(5), {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
doc.fontSize(10);
|
||||
doc.font(this.font);
|
||||
doc.text(`${utils.formatIBAN(this.data.creditor.account)}
|
||||
${this.formatAddress(this.data.creditor)}`, {
|
||||
lineGap: -0.75,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
doc.fontSize(9);
|
||||
doc.moveDown();
|
||||
if (this.data.reference !== void 0) {
|
||||
doc.fontSize(8);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].reference, {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
doc.fontSize(10);
|
||||
doc.font(this.font);
|
||||
doc.text(utils.formatReference(this.data.reference), {
|
||||
lineGap: -0.75,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
doc.fontSize(9);
|
||||
doc.moveDown();
|
||||
}
|
||||
if (this.data.message !== void 0 || this.data.additionalInformation !== void 0) {
|
||||
doc.fontSize(8);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].additionalInformation, {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
doc.fontSize(10);
|
||||
doc.font(this.font);
|
||||
const options = {
|
||||
lineGap: -0.75,
|
||||
width: utils.mm2pt(87)
|
||||
};
|
||||
const singleLineHeight = doc.heightOfString("A", options);
|
||||
const referenceType = utils.getReferenceType(this.data.reference);
|
||||
const maxLines = referenceType === "QRR" || referenceType === "SCOR" ? 3 : 4;
|
||||
const linesOfAdditionalInformation = this.data.additionalInformation !== void 0 ? doc.heightOfString(this.data.additionalInformation, options) / singleLineHeight : 0;
|
||||
if (this.data.additionalInformation !== void 0) {
|
||||
if (referenceType === "QRR" || referenceType === "SCOR") {
|
||||
if (this.data.message !== void 0) {
|
||||
doc.text(this.data.message, __spreadProps(__spreadValues({}, options), { ellipsis: true, height: singleLineHeight, lineBreak: false }));
|
||||
}
|
||||
} else {
|
||||
if (this.data.message !== void 0) {
|
||||
const maxLinesOfMessage = maxLines - linesOfAdditionalInformation;
|
||||
doc.text(this.data.message, __spreadProps(__spreadValues({}, options), { ellipsis: true, height: singleLineHeight * maxLinesOfMessage, lineBreak: true }));
|
||||
}
|
||||
}
|
||||
doc.text(this.data.additionalInformation, options);
|
||||
} else if (this.data.message !== void 0) {
|
||||
doc.text(this.data.message, __spreadProps(__spreadValues({}, options), { ellipsis: true, height: singleLineHeight * maxLines, lineBreak: true }));
|
||||
}
|
||||
doc.fontSize(9);
|
||||
doc.moveDown();
|
||||
}
|
||||
if (this.data.debtor !== void 0) {
|
||||
doc.fontSize(8);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].payableBy, {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
doc.fontSize(10);
|
||||
doc.font(this.font);
|
||||
doc.text(this.formatAddress(this.data.debtor), {
|
||||
lineGap: -0.75,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
} else {
|
||||
doc.fontSize(8);
|
||||
doc.font(`${this.font}-Bold`);
|
||||
doc.text(translations.translations[this.language].payableByName, {
|
||||
lineGap: 1,
|
||||
width: utils.mm2pt(87)
|
||||
});
|
||||
this.addRectangle(doc, 118, utils.pt2mm(doc.y - this.y()), 65, 25);
|
||||
}
|
||||
}
|
||||
formatAddress(data) {
|
||||
const countryPrefix = data.country !== "CH" ? `${data.country} - ` : "";
|
||||
if (data.buildingNumber !== void 0) {
|
||||
return `${data.name}
|
||||
${data.address} ${data.buildingNumber}
|
||||
${countryPrefix}${data.zip} ${data.city}`;
|
||||
}
|
||||
return `${data.name}
|
||||
${data.address}
|
||||
${countryPrefix}${data.zip} ${data.city}`;
|
||||
}
|
||||
addRectangle(doc, x, y, width, height) {
|
||||
const length = 3;
|
||||
doc.moveTo(this.x(x + length), this.y(y)).lineTo(this.x(x), this.y(y)).lineTo(this.x(x), this.y(y + length)).moveTo(this.x(x), this.y(y + height - length)).lineTo(this.x(x), this.y(y + height)).lineTo(this.x(x + length), this.y(y + height)).moveTo(this.x(x + width - length), this.y(y + height)).lineTo(this.x(x + width), this.y(y + height)).lineTo(this.x(x + width), this.y(y + height - length)).moveTo(this.x(x + width), this.y(y + length)).lineTo(this.x(x + width), this.y(y)).lineTo(this.x(x + width - length), this.y(y)).lineWidth(0.75).undash().strokeColor("black").stroke();
|
||||
}
|
||||
};
|
||||
_SwissQRBill.width = utils.mm2pt(210);
|
||||
_SwissQRBill.height = utils.mm2pt(105);
|
||||
let SwissQRBill = _SwissQRBill;
|
||||
exports.SwissQRBill = SwissQRBill;
|
||||
89
node_modules/swissqrbill/lib/cjs/pdf/swissqrbill.d.ts
generated
vendored
Normal file
89
node_modules/swissqrbill/lib/cjs/pdf/swissqrbill.d.ts
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
import { Data, PDFOptions } from '../shared/types.js';
|
||||
/**
|
||||
* The SwissQRBill class creates the Payment Part with the QR Code. It can be attached to any PDFKit document instance
|
||||
* using the {@link SwissQRBill.attachTo} method.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const data = {
|
||||
* amount: 1994.75,
|
||||
* creditor: {
|
||||
* account: "CH44 3199 9123 0008 8901 2",
|
||||
* address: "Musterstrasse",
|
||||
* buildingNumber: 7,
|
||||
* city: "Musterstadt",
|
||||
* country: "CH",
|
||||
* name: "SwissQRBill",
|
||||
* zip: 1234
|
||||
* },
|
||||
* currency: "CHF",
|
||||
* debtor: {
|
||||
* address: "Musterstrasse",
|
||||
* buildingNumber: 1,
|
||||
* city: "Musterstadt",
|
||||
* country: "CH",
|
||||
* name: "Peter Muster",
|
||||
* zip: 1234
|
||||
* },
|
||||
* reference: "21 00000 00003 13947 14300 09017"
|
||||
* };
|
||||
*
|
||||
* const pdf = new PDFDocument({ autoFirstPage: false });
|
||||
* const qrBill = new SwissQRBill(data);
|
||||
*
|
||||
* const stream = createWriteStream("qr-bill.pdf");
|
||||
*
|
||||
* qrBill.attachTo(pdf);
|
||||
* pdf.pipe(stream);
|
||||
* pdf.end();
|
||||
* ```
|
||||
*/
|
||||
export declare class SwissQRBill {
|
||||
private data;
|
||||
private scissors;
|
||||
private separate;
|
||||
private outlines;
|
||||
private language;
|
||||
private font;
|
||||
private _x;
|
||||
private _y;
|
||||
/**
|
||||
* Creates a new SwissQRBill instance.
|
||||
*
|
||||
* @param data The data to be used for the QR Bill.
|
||||
* @param options Options to define how the QR Bill should be rendered.
|
||||
* @throws { ValidationError } Throws an error if the data is invalid.
|
||||
*/
|
||||
constructor(data: Data, options?: PDFOptions);
|
||||
/**
|
||||
* Attaches the QR-Bill to a PDFKit document instance. It will create a new page with the size of the QR-Slip if not
|
||||
* enough space is left on the current page.
|
||||
*
|
||||
* @param doc The PDFKit instance.
|
||||
* @param x The horizontal position in points where the QR Bill will be placed.
|
||||
* @param y The vertical position in points where the QR Bill will be placed.
|
||||
*/
|
||||
attachTo(doc: PDFKit.PDFDocument, x?: number, y?: number): void;
|
||||
/**
|
||||
* Checks whether there is enough space on the current page to add the QR Bill.
|
||||
*
|
||||
* @param doc The PDFKit document instance.
|
||||
* @param x The horizontal position where the QR Bill will be placed.
|
||||
* @param y The vertical position where the QR Bill will be placed.
|
||||
* @returns `true` if there is enough space, otherwise `false`.
|
||||
*/
|
||||
static isSpaceSufficient(doc: PDFKit.PDFDocument, x?: number, y?: number): boolean;
|
||||
/**
|
||||
* The horizontal size of the QR Bill.
|
||||
*/
|
||||
static readonly width: number;
|
||||
/**
|
||||
* The vertical size of the QR Bill.
|
||||
*/
|
||||
static readonly height: number;
|
||||
private x;
|
||||
private y;
|
||||
private render;
|
||||
private formatAddress;
|
||||
private addRectangle;
|
||||
}
|
||||
51
node_modules/swissqrbill/lib/cjs/pdf/swissqrcode.cjs
generated
vendored
Normal file
51
node_modules/swissqrbill/lib/cjs/pdf/swissqrcode.cjs
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const cleaner = require("../shared/cleaner.cjs");
|
||||
const qrCode = require("../shared/qr-code.cjs");
|
||||
const validator = require("../shared/validator.cjs");
|
||||
const utils = require("../shared/utils.cjs");
|
||||
class SwissQRCode {
|
||||
/**
|
||||
* Creates a Swiss QR Code.
|
||||
*
|
||||
* @param data The data to be encoded in the QR code.
|
||||
* @param size The size of the QR code in mm.
|
||||
* @throws { ValidationError } Throws an error if the data is invalid.
|
||||
*/
|
||||
constructor(data, size = 46) {
|
||||
this.size = utils.mm2pt(size);
|
||||
this.data = cleaner.cleanData(data);
|
||||
validator.validateData(this.data);
|
||||
}
|
||||
/**
|
||||
* Attaches the Swiss QR Code to a PDF document.
|
||||
*
|
||||
* @param doc The PDF document to attach the Swiss QR Code to.
|
||||
* @param x The horizontal position in points where the Swiss QR Code will be placed.
|
||||
* @param y The vertical position in points where the Swiss QR Code will be placed.
|
||||
*/
|
||||
attachTo(doc, x = ((_a) => (_a = doc.x) != null ? _a : 0)(), y = ((_b) => (_b = doc.y) != null ? _b : 0)()) {
|
||||
doc.save();
|
||||
doc.translate(x, y);
|
||||
qrCode.renderQRCode(this.data, this.size, (xPos, yPos, blockSize) => {
|
||||
doc.rect(
|
||||
xPos,
|
||||
yPos,
|
||||
blockSize,
|
||||
blockSize
|
||||
);
|
||||
});
|
||||
doc.fillColor("black");
|
||||
doc.fill();
|
||||
qrCode.renderSwissCross(this.size, (xPos, yPos, width, height, fillColor) => {
|
||||
doc.rect(
|
||||
xPos,
|
||||
yPos,
|
||||
width,
|
||||
height
|
||||
).fillColor(fillColor).fill();
|
||||
});
|
||||
doc.restore();
|
||||
}
|
||||
}
|
||||
exports.SwissQRCode = SwissQRCode;
|
||||
21
node_modules/swissqrbill/lib/cjs/pdf/swissqrcode.d.ts
generated
vendored
Normal file
21
node_modules/swissqrbill/lib/cjs/pdf/swissqrcode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Data } from '../shared/types.js';
|
||||
export declare class SwissQRCode {
|
||||
private size;
|
||||
private data;
|
||||
/**
|
||||
* Creates a Swiss QR Code.
|
||||
*
|
||||
* @param data The data to be encoded in the QR code.
|
||||
* @param size The size of the QR code in mm.
|
||||
* @throws { ValidationError } Throws an error if the data is invalid.
|
||||
*/
|
||||
constructor(data: Data, size?: number);
|
||||
/**
|
||||
* Attaches the Swiss QR Code to a PDF document.
|
||||
*
|
||||
* @param doc The PDF document to attach the Swiss QR Code to.
|
||||
* @param x The horizontal position in points where the Swiss QR Code will be placed.
|
||||
* @param y The vertical position in points where the Swiss QR Code will be placed.
|
||||
*/
|
||||
attachTo(doc: PDFKit.PDFDocument, x?: number, y?: number): void;
|
||||
}
|
||||
255
node_modules/swissqrbill/lib/cjs/pdf/table.cjs
generated
vendored
Normal file
255
node_modules/swissqrbill/lib/cjs/pdf/table.cjs
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
var TableLayer = /* @__PURE__ */ ((TableLayer2) => {
|
||||
TableLayer2[TableLayer2["HeightCalculation"] = 0] = "HeightCalculation";
|
||||
TableLayer2[TableLayer2["PageInjection"] = 1] = "PageInjection";
|
||||
TableLayer2[TableLayer2["BackgroundColor"] = 2] = "BackgroundColor";
|
||||
TableLayer2[TableLayer2["Borders"] = 3] = "Borders";
|
||||
TableLayer2[TableLayer2["Text"] = 4] = "Text";
|
||||
return TableLayer2;
|
||||
})(TableLayer || {});
|
||||
class Table {
|
||||
/**
|
||||
* Creates a new Table instance.
|
||||
*
|
||||
* @param data The rows and columns for the table.
|
||||
* @returns The Table instance.
|
||||
*/
|
||||
constructor(data) {
|
||||
this.data = data;
|
||||
}
|
||||
// Hacky workaround to get the current page of the document
|
||||
getCurrentPage(doc) {
|
||||
const page = doc.page;
|
||||
for (let i = doc.bufferedPageRange().start; i < doc.bufferedPageRange().count; i++) {
|
||||
doc.switchToPage(i);
|
||||
if (doc.page === page) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return doc.bufferedPageRange().count;
|
||||
}
|
||||
/**
|
||||
* Attaches the table to a PDFKit document instance beginning on the current page. It will create a new page with for
|
||||
* every row that no longer fits on a page.
|
||||
*
|
||||
* @param doc The PDFKit document instance.
|
||||
* @param x The horizontal position in points where the table be placed.
|
||||
* @param y The vertical position in points where the table will be placed.
|
||||
* @throws { Error } Throws an error if no table rows are provided.
|
||||
*/
|
||||
attachTo(doc, x = ((_a) => (_a = doc.x) != null ? _a : 0)(), y = ((_b) => (_b = doc.y) != null ? _b : 0)()) {
|
||||
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
||||
if (this.data.rows === void 0) {
|
||||
throw new Error("No table rows provided.");
|
||||
}
|
||||
if (!doc.page) {
|
||||
doc.addPage({ size: "A4" });
|
||||
}
|
||||
doc.options.bufferPages = true;
|
||||
const tableX = x;
|
||||
const tableY = y;
|
||||
const startPage = this.getCurrentPage(doc);
|
||||
const tableWidth = this.data.width ? this.data.width : doc.page.width - tableX - doc.page.margins.right;
|
||||
const tableBackgroundColor = this.data.backgroundColor ? this.data.backgroundColor : void 0;
|
||||
const tableBorder = this.data.borderWidth ? this.data.borderWidth : void 0;
|
||||
const tableBorderColors = this.data.borderColor ? this.data.borderColor : "#000000";
|
||||
const tablePadding = this.data.padding ? this.data.padding : 0;
|
||||
const tableFontSize = this.data.fontSize ? this.data.fontSize : 11;
|
||||
const tableTextColor = this.data.textColor ? this.data.textColor : "#000000";
|
||||
const tableFont = this.data.fontName ? this.data.fontName : "Helvetica";
|
||||
const tableAlign = this.data.align ? this.data.align : void 0;
|
||||
const tableVerticalAlign = this.data.verticalAlign ? this.data.verticalAlign : "top";
|
||||
const headerRowIndex = this.data.rows.findIndex((row) => !!row.header);
|
||||
const autoRowHeights = [];
|
||||
for (let layer = 0; layer < Object.values(TableLayer).length / 2; layer++) {
|
||||
doc.switchToPage(startPage);
|
||||
let rowY = tableY;
|
||||
rowLoop: for (let rowIndex = 0; rowIndex < this.data.rows.length; rowIndex++) {
|
||||
const row = this.data.rows[rowIndex];
|
||||
const rowHeight = autoRowHeights[rowIndex];
|
||||
const minRowHeight = row.minHeight;
|
||||
const maxRowHeight = row.maxHeight;
|
||||
const rowPadding = row.padding ? row.padding : tablePadding;
|
||||
const rowBackgroundColor = row.backgroundColor ? row.backgroundColor : tableBackgroundColor;
|
||||
const rowBorder = row.borderWidth ? row.borderWidth : tableBorder;
|
||||
const rowBorderColors = row.borderColor ? row.borderColor : tableBorderColors;
|
||||
const rowFontSize = row.fontSize ? row.fontSize : tableFontSize;
|
||||
const rowFont = row.fontName ? row.fontName : tableFont;
|
||||
const rowTextColor = row.textColor ? row.textColor : tableTextColor;
|
||||
const rowAlign = row.align ? row.align : tableAlign;
|
||||
const rowVerticalAlign = row.verticalAlign ? row.verticalAlign : tableVerticalAlign;
|
||||
doc.moveTo(tableX, tableY);
|
||||
let columnX = tableX;
|
||||
columnLoop: for (let columnIndex = 0; columnIndex < row.columns.length; columnIndex++) {
|
||||
const column = row.columns[columnIndex];
|
||||
const { remainingColumns, widthUsed } = row.columns.reduce((acc, column2) => {
|
||||
if (column2.width !== void 0) {
|
||||
acc.widthUsed += column2.width;
|
||||
acc.remainingColumns--;
|
||||
}
|
||||
return acc;
|
||||
}, { remainingColumns: row.columns.length, widthUsed: 0 });
|
||||
const columnWidth = column.width ? column.width : (tableWidth - widthUsed) / remainingColumns;
|
||||
const columnPadding = column.padding ? column.padding : rowPadding;
|
||||
const columnBackgroundColor = column.backgroundColor ? column.backgroundColor : rowBackgroundColor;
|
||||
const columnBorder = column.borderWidth ? column.borderWidth : rowBorder;
|
||||
const columnBorderColors = column.borderColor ? column.borderColor : rowBorderColors;
|
||||
const columnFontSize = column.fontSize ? column.fontSize : rowFontSize;
|
||||
const columnFont = column.fontName ? column.fontName : rowFont;
|
||||
const columnTextColor = column.textColor ? column.textColor : rowTextColor;
|
||||
const columnAlign = column.align ? column.align : rowAlign;
|
||||
const columnVerticalAlign = column.verticalAlign ? column.verticalAlign : rowVerticalAlign;
|
||||
const fillOpacity = columnBackgroundColor === void 0 ? 0 : 1;
|
||||
const borderOpacity = columnBorderColors === void 0 ? 0 : 1;
|
||||
const paddings = this._positionsToObject(columnPadding);
|
||||
doc.moveTo(columnX + columnWidth, rowY);
|
||||
const textOptions = __spreadProps(__spreadValues({}, (_a2 = column.textOptions) != null ? _a2 : {}), {
|
||||
align: columnAlign,
|
||||
baseline: "middle",
|
||||
height: rowHeight !== void 0 ? rowHeight - ((_b2 = paddings.top) != null ? _b2 : 0) - ((_c = paddings.bottom) != null ? _c : 0) : void 0,
|
||||
lineBreak: true,
|
||||
width: columnWidth - ((_d = paddings.left) != null ? _d : 0) - ((_e = paddings.right) != null ? _e : 0)
|
||||
});
|
||||
doc.font(columnFont);
|
||||
doc.fontSize(columnFontSize);
|
||||
const textHeight = doc.heightOfString(`${column.text}`, textOptions);
|
||||
const singleLineHeight = doc.heightOfString("A", textOptions);
|
||||
if (layer === 0) {
|
||||
if (autoRowHeights[rowIndex] === void 0 || autoRowHeights[rowIndex] < textHeight + ((_f = paddings.top) != null ? _f : 0) + ((_g = paddings.bottom) != null ? _g : 0)) {
|
||||
autoRowHeights[rowIndex] = textHeight + ((_h = paddings.top) != null ? _h : 0) + ((_i = paddings.bottom) != null ? _i : 0);
|
||||
if (minRowHeight !== void 0 && autoRowHeights[rowIndex] < minRowHeight) {
|
||||
autoRowHeights[rowIndex] = minRowHeight;
|
||||
}
|
||||
if (maxRowHeight !== void 0 && autoRowHeights[rowIndex] > maxRowHeight) {
|
||||
autoRowHeights[rowIndex] = maxRowHeight;
|
||||
}
|
||||
}
|
||||
if (row.height !== void 0) {
|
||||
autoRowHeights[rowIndex] = row.height;
|
||||
}
|
||||
if (columnIndex < row.columns.length - 1) {
|
||||
continue columnLoop;
|
||||
} else {
|
||||
continue rowLoop;
|
||||
}
|
||||
}
|
||||
if (layer === 1) {
|
||||
if (rowY + rowHeight >= doc.page.height - doc.page.margins.bottom) {
|
||||
doc.addPage();
|
||||
rowY = doc.y;
|
||||
const headerRow = this.data.rows[headerRowIndex];
|
||||
if (headerRow !== void 0) {
|
||||
this.data.rows.splice(rowIndex, 0, headerRow);
|
||||
autoRowHeights.splice(rowIndex, 0, autoRowHeights[headerRowIndex]);
|
||||
rowIndex--;
|
||||
continue rowLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (layer > 1) {
|
||||
if (!!row.header && rowY !== ((_j = doc.page.margins.top) != null ? _j : 0) && rowIndex !== headerRowIndex || rowY + rowHeight >= doc.page.height - doc.page.margins.bottom) {
|
||||
doc.switchToPage(this.getCurrentPage(doc) + 1);
|
||||
doc.x = tableX;
|
||||
doc.y = (_k = doc.page.margins.top) != null ? _k : 0;
|
||||
rowY = doc.y;
|
||||
}
|
||||
}
|
||||
if (layer === 2) {
|
||||
if (columnBackgroundColor !== void 0) {
|
||||
doc.rect(columnX, rowY, columnWidth, rowHeight).fillColor(columnBackgroundColor).fillOpacity(fillOpacity).fill();
|
||||
}
|
||||
}
|
||||
if (layer === 4) {
|
||||
let textPosY = rowY;
|
||||
if (columnVerticalAlign === "top") {
|
||||
textPosY = rowY + ((_l = paddings.top) != null ? _l : 0) + singleLineHeight / 2;
|
||||
} else if (columnVerticalAlign === "center") {
|
||||
textPosY = rowY + rowHeight / 2 - textHeight / 2 + singleLineHeight / 2;
|
||||
} else if (columnVerticalAlign === "bottom") {
|
||||
textPosY = rowY + rowHeight - ((_m = paddings.bottom) != null ? _m : 0) - textHeight + singleLineHeight / 2;
|
||||
}
|
||||
if (textPosY < rowY + ((_n = paddings.top) != null ? _n : 0) + singleLineHeight / 2) {
|
||||
textPosY = rowY + ((_o = paddings.top) != null ? _o : 0) + singleLineHeight / 2;
|
||||
}
|
||||
doc.fillColor(columnTextColor).fillOpacity(1);
|
||||
doc.text(`${column.text}`, columnX + ((_p = paddings.left) != null ? _p : 0), textPosY, textOptions);
|
||||
}
|
||||
if (layer === 3) {
|
||||
if (columnBorder !== void 0 && columnBorderColors !== void 0) {
|
||||
const border = this._positionsToObject(columnBorder);
|
||||
const borderColor = this._positionsToObject(columnBorderColors);
|
||||
doc.undash().lineJoin("miter").lineCap("butt").strokeOpacity(borderOpacity);
|
||||
if (border.left && borderColor.left) {
|
||||
const borderBottomMargin = border.bottom ? border.bottom / 2 : 0;
|
||||
const borderTopMargin = border.top ? border.top / 2 : 0;
|
||||
doc.moveTo(columnX, rowY + rowHeight + borderBottomMargin);
|
||||
doc.lineTo(columnX, rowY - borderTopMargin).strokeColor(borderColor.left).lineWidth(border.left).stroke();
|
||||
}
|
||||
if (border.right && borderColor.right) {
|
||||
const borderTopMargin = border.top ? border.top / 2 : 0;
|
||||
const borderBottomMargin = border.bottom ? border.bottom / 2 : 0;
|
||||
doc.moveTo(columnX + columnWidth, rowY - borderTopMargin);
|
||||
doc.lineTo(columnX + columnWidth, rowY + rowHeight + borderBottomMargin).strokeColor(borderColor.right).lineWidth(border.right).stroke();
|
||||
}
|
||||
if (border.top && borderColor.top) {
|
||||
const borderLeftMargin = border.left ? border.left / 2 : 0;
|
||||
const borderRightMargin = border.right ? border.right / 2 : 0;
|
||||
doc.moveTo(columnX - borderLeftMargin, rowY);
|
||||
doc.lineTo(columnX + columnWidth + borderRightMargin, rowY).strokeColor(borderColor.top).lineWidth(border.top).stroke();
|
||||
}
|
||||
if (border.bottom && borderColor.bottom) {
|
||||
const borderRightMargin = border.right ? border.right / 2 : 0;
|
||||
const borderLeftMargin = border.left ? border.left / 2 : 0;
|
||||
doc.moveTo(columnX + columnWidth + borderRightMargin, rowY + rowHeight);
|
||||
doc.lineTo(columnX - borderLeftMargin, rowY + rowHeight).strokeColor(borderColor.bottom).lineWidth(border.bottom).stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
columnX += columnWidth;
|
||||
}
|
||||
rowY += rowHeight;
|
||||
doc.x = columnX;
|
||||
doc.y = rowY;
|
||||
}
|
||||
}
|
||||
doc.x = tableX;
|
||||
}
|
||||
_positionsToObject(numberOrPositions) {
|
||||
if (typeof numberOrPositions === "number" || typeof numberOrPositions === "string") {
|
||||
return {
|
||||
bottom: numberOrPositions,
|
||||
left: numberOrPositions,
|
||||
right: numberOrPositions,
|
||||
top: numberOrPositions
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
bottom: numberOrPositions[2] !== void 0 ? numberOrPositions[2] : numberOrPositions[0],
|
||||
left: numberOrPositions[3] !== void 0 ? numberOrPositions[3] : numberOrPositions[1],
|
||||
right: numberOrPositions[1] !== void 0 ? numberOrPositions[1] : void 0,
|
||||
top: numberOrPositions[0]
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Table = Table;
|
||||
154
node_modules/swissqrbill/lib/cjs/pdf/table.d.ts
generated
vendored
Normal file
154
node_modules/swissqrbill/lib/cjs/pdf/table.d.ts
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
export interface PDFTable {
|
||||
/** Table rows. */
|
||||
rows: PDFRow[];
|
||||
/** Horizontal alignment of texts inside the table. */
|
||||
align?: "center" | "left" | "right";
|
||||
/** Background color of the table. */
|
||||
backgroundColor?: string;
|
||||
/** The colors of the border. */
|
||||
borderColor?: PDFBorderColor;
|
||||
/** Width of the borders of the row. */
|
||||
borderWidth?: PDFBorderWidth;
|
||||
/** Font of the text inside the table. */
|
||||
fontName?: string;
|
||||
/** Font size of the text inside the table. */
|
||||
fontSize?: number;
|
||||
/** Cell padding of the table cells. */
|
||||
padding?: PDFPadding;
|
||||
/** Text color of texts inside table. */
|
||||
textColor?: string;
|
||||
/** Same as text [PDFKit text options](http://pdfkit.org/docs/text.html#text_styling). */
|
||||
textOptions?: PDFKit.Mixins.TextOptions;
|
||||
/** Vertical alignment of texts inside the table. */
|
||||
verticalAlign?: "bottom" | "center" | "top";
|
||||
/** Width of whole table. */
|
||||
width?: number;
|
||||
}
|
||||
export interface PDFRow {
|
||||
/** Table columns. */
|
||||
columns: PDFColumn[];
|
||||
/** Horizontal alignment of texts inside the row. */
|
||||
align?: "center" | "left" | "right";
|
||||
/** Background color of the row. */
|
||||
backgroundColor?: string;
|
||||
/** The colors of the border. */
|
||||
borderColor?: PDFBorderColor;
|
||||
/** Width of the borders of the row. */
|
||||
borderWidth?: PDFBorderWidth;
|
||||
/** Font of the text inside the row. */
|
||||
fontName?: string;
|
||||
/** Font size of the text inside the row. */
|
||||
fontSize?: number;
|
||||
/** A header row gets inserted automatically on new pages. Only one header row is allowed. */
|
||||
header?: boolean;
|
||||
/** Height of the row. Overrides minHeight and maxHeight. */
|
||||
height?: number;
|
||||
/** Maximum height of the row. */
|
||||
maxHeight?: number;
|
||||
/** Minimum height of the row. */
|
||||
minHeight?: number;
|
||||
/** Cell padding of the table cells inside the row. */
|
||||
padding?: PDFPadding;
|
||||
/** Text color of texts inside the row. */
|
||||
textColor?: string;
|
||||
/** Same as text [PDFKit text options](http://pdfkit.org/docs/text.html#text_styling). */
|
||||
textOptions?: PDFKit.Mixins.TextOptions;
|
||||
/** Vertical alignment of texts inside the row. */
|
||||
verticalAlign?: "bottom" | "center" | "top";
|
||||
}
|
||||
export interface PDFColumn {
|
||||
/** Cell text. */
|
||||
text: boolean | number | string;
|
||||
/** Horizontal alignment of the text inside the cell. */
|
||||
align?: "center" | "left" | "right";
|
||||
/** Background color of the cell. */
|
||||
backgroundColor?: string;
|
||||
/** The colors of the border. */
|
||||
borderColor?: PDFBorderColor;
|
||||
/** Width of the borders of the row. */
|
||||
borderWidth?: PDFBorderWidth;
|
||||
/** Font of the text inside the cell. */
|
||||
fontName?: string;
|
||||
/** Font size of the text inside the cell. */
|
||||
fontSize?: number;
|
||||
/** Cell padding of the table cell. */
|
||||
padding?: PDFPadding;
|
||||
/** Text color of texts inside the cell. */
|
||||
textColor?: string;
|
||||
/** Same as text [PDFKit text options](http://pdfkit.org/docs/text.html#text_styling). */
|
||||
textOptions?: PDFKit.Mixins.TextOptions;
|
||||
/** Vertical alignment of the text inside the cell. */
|
||||
verticalAlign?: "bottom" | "center" | "top";
|
||||
/** Width of the cell. */
|
||||
width?: number;
|
||||
}
|
||||
/** Can be used to set the color of the border of a table, row or column. */
|
||||
export type PDFBorderColor = string | [top?: string, right?: string, bottom?: string, left?: string] | [vertical?: string, horizontal?: string];
|
||||
/** Can be used to set the width of the border of a table, row or column. */
|
||||
export type PDFBorderWidth = number | [top?: number, right?: number, bottom?: number, left?: number] | [vertical?: number, horizontal?: number];
|
||||
/** Can be used to set the padding of a table cell. */
|
||||
export type PDFPadding = number | [top?: number, right?: number, bottom?: number, left?: number] | [vertical?: number, horizontal?: number];
|
||||
/**
|
||||
* The Table class is used to create tables for PDFKit documents. A table can be attached to any PDFKit document instance
|
||||
* using the {@link Table.attachTo} method.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const tableData = {
|
||||
* rows: [
|
||||
* {
|
||||
* backgroundColor: "#ECF0F1",
|
||||
* columns: [
|
||||
* {
|
||||
* text: "Row 1 cell 1"
|
||||
* }, {
|
||||
* text: "Row 1 cell 2"
|
||||
* }, {
|
||||
* text: "Row 1 cell 3"
|
||||
* }
|
||||
* ]
|
||||
* }, {
|
||||
* columns: [
|
||||
* {
|
||||
* text: "Row 2 cell 1"
|
||||
* }, {
|
||||
* text: "Row 2 cell 2"
|
||||
* }, {
|
||||
* text: "Row 2 cell 3"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* };
|
||||
* const pdf = new PDFDocument();
|
||||
* const table = new Table(tableData);
|
||||
*
|
||||
* const stream = createWriteStream("table.pdf");
|
||||
*
|
||||
* table.attachTo(pdf);
|
||||
* pdf.pipe(stream);
|
||||
* pdf.end();
|
||||
* ```
|
||||
*/
|
||||
export declare class Table {
|
||||
private data;
|
||||
/**
|
||||
* Creates a new Table instance.
|
||||
*
|
||||
* @param data The rows and columns for the table.
|
||||
* @returns The Table instance.
|
||||
*/
|
||||
constructor(data: PDFTable);
|
||||
private getCurrentPage;
|
||||
/**
|
||||
* Attaches the table to a PDFKit document instance beginning on the current page. It will create a new page with for
|
||||
* every row that no longer fits on a page.
|
||||
*
|
||||
* @param doc The PDFKit document instance.
|
||||
* @param x The horizontal position in points where the table be placed.
|
||||
* @param y The vertical position in points where the table will be placed.
|
||||
* @throws { Error } Throws an error if no table rows are provided.
|
||||
*/
|
||||
attachTo(doc: PDFKit.PDFDocument, x?: number, y?: number): void;
|
||||
private _positionsToObject;
|
||||
}
|
||||
36
node_modules/swissqrbill/lib/cjs/shared/cleaner.cjs
generated
vendored
Normal file
36
node_modules/swissqrbill/lib/cjs/shared/cleaner.cjs
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
function cleanData(data) {
|
||||
const _cleanObject = (object) => {
|
||||
return Object.fromEntries(
|
||||
Object.entries(object).map(([key, value]) => {
|
||||
if (typeof value === "object") {
|
||||
return [key, _cleanObject(value)];
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
if (key === "account") {
|
||||
return [key, removeLineBreaks(removeSpaces(value))];
|
||||
}
|
||||
if (key === "reference") {
|
||||
return [key, removeLineBreaks(removeSpaces(value))];
|
||||
}
|
||||
if (key === "country") {
|
||||
return [key, removeLineBreaks(removeSpaces(value).toUpperCase())];
|
||||
}
|
||||
return [key, removeLineBreaks(value)];
|
||||
}
|
||||
return [key, value];
|
||||
})
|
||||
);
|
||||
};
|
||||
return _cleanObject(data);
|
||||
}
|
||||
function removeSpaces(text) {
|
||||
return text.replace(/ /g, "");
|
||||
}
|
||||
function removeLineBreaks(text) {
|
||||
return text.replace(/\n/g, "").replace(/\r/g, "");
|
||||
}
|
||||
exports.cleanData = cleanData;
|
||||
exports.removeLineBreaks = removeLineBreaks;
|
||||
exports.removeSpaces = removeSpaces;
|
||||
4
node_modules/swissqrbill/lib/cjs/shared/cleaner.d.ts
generated
vendored
Normal file
4
node_modules/swissqrbill/lib/cjs/shared/cleaner.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Data } from './types.js';
|
||||
export declare function cleanData(data: Data): Data;
|
||||
export declare function removeSpaces(text: string): string;
|
||||
export declare function removeLineBreaks(text: string): string;
|
||||
88
node_modules/swissqrbill/lib/cjs/shared/errors.cjs
generated
vendored
Normal file
88
node_modules/swissqrbill/lib/cjs/shared/errors.cjs
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
class ValidationError extends Error {
|
||||
/** @internal */
|
||||
constructor(message, params) {
|
||||
const messageWithParams = params ? resolveMessageParams(message, params) : message;
|
||||
super(messageWithParams);
|
||||
this.name = "ValidationError";
|
||||
this.code = getErrorCodeByMessage(message);
|
||||
}
|
||||
}
|
||||
function getErrorCodeByMessage(message) {
|
||||
const errorCodes = Object.keys(ValidationErrors);
|
||||
const errorCode = errorCodes.find((key) => ValidationErrors[key] === message);
|
||||
return errorCode;
|
||||
}
|
||||
function resolveMessageParams(message, params) {
|
||||
return Object.entries(params).reduce((message2, [key, value]) => {
|
||||
return message2.replace(`{${key}}`, value);
|
||||
}, message);
|
||||
}
|
||||
var ValidationErrors = /* @__PURE__ */ ((ValidationErrors2) => {
|
||||
ValidationErrors2["ACCOUNT_IS_QR_IBAN_BUT_REFERENCE_IS_MISSING"] = "If there is no reference, a conventional IBAN must be used.";
|
||||
ValidationErrors2["ACCOUNT_IS_QR_IBAN_BUT_REFERENCE_IS_REGULAR"] = "QR-IBAN requires the use of a QR-Reference.";
|
||||
ValidationErrors2["ACCOUNT_IS_REGULAR_IBAN_BUT_REFERENCE_IS_QR"] = "QR-Reference requires the use of a QR-IBAN.";
|
||||
ValidationErrors2["ACCOUNT_LENGTH_IS_INVALID"] = "The provided IBAN number '{iban}' is either too long or too short.";
|
||||
ValidationErrors2["ADDITIONAL_INFORMATION_LENGTH_IS_INVALID"] = "Additional information must be a maximum of 140 characters.";
|
||||
ValidationErrors2["ADDITIONAL_INFORMATION_TYPE_IS_INVALID"] = "Additional information must be a string.";
|
||||
ValidationErrors2["ALTERNATIVE_SCHEME_LENGTH_IS_INVALID"] = "{scheme} must be a maximum of 100 characters.";
|
||||
ValidationErrors2["ALTERNATIVE_SCHEME_TYPE_IS_INVALID"] = "{scheme} must be a string.";
|
||||
ValidationErrors2["AMOUNT_LENGTH_IS_INVALID"] = "Amount must be a maximum of 12 digits.";
|
||||
ValidationErrors2["AMOUNT_TYPE_IS_INVALID"] = "Amount must be a number.";
|
||||
ValidationErrors2["CREDITOR_ACCOUNT_COUNTRY_IS_INVALID"] = "Only CH and LI IBAN numbers are allowed.";
|
||||
ValidationErrors2["CREDITOR_ACCOUNT_IS_INVALID"] = "The provided IBAN number '{iban}' is not valid.";
|
||||
ValidationErrors2["CREDITOR_ACCOUNT_IS_UNDEFINED"] = "Creditor account cannot be undefined.";
|
||||
ValidationErrors2["CREDITOR_ADDRESS_IS_UNDEFINED"] = "Creditor address cannot be undefined.";
|
||||
ValidationErrors2["CREDITOR_ADDRESS_LENGTH_IS_INVALID"] = "Creditor address must be a maximum of 70 characters.";
|
||||
ValidationErrors2["CREDITOR_ADDRESS_TYPE_IS_INVALID"] = "Creditor address TYPE must be a string.";
|
||||
ValidationErrors2["CREDITOR_BUILDING_NUMBER_LENGTH_IS_INVALID"] = "Creditor buildingNumber must be a maximum of 16 characters.";
|
||||
ValidationErrors2["CREDITOR_BUILDING_NUMBER_TYPE_IS_INVALID"] = "Creditor buildingNumber must be either a string or a number.";
|
||||
ValidationErrors2["CREDITOR_CITY_IS_UNDEFINED"] = "Creditor city cannot be undefined.";
|
||||
ValidationErrors2["CREDITOR_CITY_LENGTH_IS_INVALID"] = "Creditor city must be a maximum of 35 characters.";
|
||||
ValidationErrors2["CREDITOR_CITY_TYPE_IS_INVALID"] = "Creditor city must be a string.";
|
||||
ValidationErrors2["CREDITOR_COUNTRY_IS_UNDEFINED"] = "Creditor country cannot be undefined.";
|
||||
ValidationErrors2["CREDITOR_COUNTRY_LENGTH_IS_INVALID"] = "Creditor country must be 2 characters.";
|
||||
ValidationErrors2["CREDITOR_COUNTRY_TYPE_IS_INVALID"] = "Creditor country must be a string.";
|
||||
ValidationErrors2["CREDITOR_IS_UNDEFINED"] = "Creditor cannot be undefined.";
|
||||
ValidationErrors2["CREDITOR_NAME_IS_UNDEFINED"] = "Creditor name cannot be undefined.";
|
||||
ValidationErrors2["CREDITOR_NAME_LENGTH_IS_INVALID"] = "Creditor name must be a maximum of 70 characters.";
|
||||
ValidationErrors2["CREDITOR_NAME_TYPE_IS_INVALID"] = "Creditor name must be a string.";
|
||||
ValidationErrors2["CREDITOR_ZIP_IS_UNDEFINED"] = "Creditor zip cannot be undefined.";
|
||||
ValidationErrors2["CREDITOR_ZIP_LENGTH_IS_INVALID"] = "Creditor zip must be a maximum of 16 characters.";
|
||||
ValidationErrors2["CREDITOR_ZIP_TYPE_IS_INVALID"] = "Creditor zip must be either a string or a number.";
|
||||
ValidationErrors2["CURRENCY_IS_UNDEFINED"] = "Currency cannot be undefined.";
|
||||
ValidationErrors2["CURRENCY_LENGTH_IS_INVALID"] = "Currency must be a length of 3 characters.";
|
||||
ValidationErrors2["CURRENCY_STRING_IS_INVALID"] = "Currency must be either 'CHF' or 'EUR'";
|
||||
ValidationErrors2["CURRENCY_TYPE_IS_INVALID"] = "Currency must be a string.";
|
||||
ValidationErrors2["DEBTOR_ADDRESS_IS_UNDEFINED"] = "Debtor address cannot be undefined.";
|
||||
ValidationErrors2["DEBTOR_ADDRESS_LENGTH_IS_INVALID"] = "Debtor address must be a maximum of 70 characters.";
|
||||
ValidationErrors2["DEBTOR_ADDRESS_TYPE_IS_INVALID"] = "Debtor address TYPE must be a string.";
|
||||
ValidationErrors2["DEBTOR_BUILDING_NUMBER_LENGTH_IS_INVALID"] = "Debtor buildingNumber must be a maximum of 16 characters.";
|
||||
ValidationErrors2["DEBTOR_BUILDING_NUMBER_TYPE_IS_INVALID"] = "Debtor buildingNumber must be either a string or a number.";
|
||||
ValidationErrors2["DEBTOR_CITY_IS_UNDEFINED"] = "Debtor city cannot be undefined.";
|
||||
ValidationErrors2["DEBTOR_CITY_LENGTH_IS_INVALID"] = "Debtor city must be a maximum of 35 characters.";
|
||||
ValidationErrors2["DEBTOR_CITY_TYPE_IS_INVALID"] = "Debtor city must be a string.";
|
||||
ValidationErrors2["DEBTOR_COUNTRY_IS_UNDEFINED"] = "Debtor country cannot be undefined.";
|
||||
ValidationErrors2["DEBTOR_COUNTRY_LENGTH_IS_INVALID"] = "Debtor country must be 2 characters.";
|
||||
ValidationErrors2["DEBTOR_COUNTRY_TYPE_IS_INVALID"] = "Debtor country must be a string.";
|
||||
ValidationErrors2["DEBTOR_IS_UNDEFINED"] = "Debtor cannot be undefined.";
|
||||
ValidationErrors2["DEBTOR_NAME_IS_UNDEFINED"] = "Debtor name cannot be undefined.";
|
||||
ValidationErrors2["DEBTOR_NAME_LENGTH_IS_INVALID"] = "Debtor name must be a maximum of 70 characters.";
|
||||
ValidationErrors2["DEBTOR_NAME_TYPE_IS_INVALID"] = "Debtor name must be a string.";
|
||||
ValidationErrors2["DEBTOR_ZIP_IS_UNDEFINED"] = "Debtor zip cannot be undefined.";
|
||||
ValidationErrors2["DEBTOR_ZIP_LENGTH_IS_INVALID"] = "Debtor zip must be a maximum of 16 characters.";
|
||||
ValidationErrors2["DEBTOR_ZIP_TYPE_IS_INVALID"] = "Debtor zip must be either a string or a number.";
|
||||
ValidationErrors2["MESSAGE_AND_ADDITIONAL_INFORMATION_LENGTH_IS_INVALID"] = "Message and additionalInformation combined must be a maximum of 140 characters.";
|
||||
ValidationErrors2["MESSAGE_LENGTH_IS_INVALID"] = "Message must be a maximum of 140 characters.";
|
||||
ValidationErrors2["MESSAGE_TYPE_IS_INVALID"] = "Message must be a string.";
|
||||
ValidationErrors2["QR_REFERENCE_IS_INVALID"] = "The provided QR-Reference '{reference}' is not valid.";
|
||||
ValidationErrors2["QR_REFERENCE_LENGTH_IS_INVALID"] = "QR-Reference must be a must be exactly 27 characters.";
|
||||
ValidationErrors2["REFERENCE_TYPE_IS_INVALID"] = "Reference must be a string.";
|
||||
ValidationErrors2["REGULAR_REFERENCE_LENGTH_IS_INVALID"] = "Creditor reference must be a maximum of 25 characters.";
|
||||
return ValidationErrors2;
|
||||
})(ValidationErrors || {});
|
||||
exports.ValidationError = ValidationError;
|
||||
exports.ValidationErrors = ValidationErrors;
|
||||
exports.getErrorCodeByMessage = getErrorCodeByMessage;
|
||||
exports.resolveMessageParams = resolveMessageParams;
|
||||
67
node_modules/swissqrbill/lib/cjs/shared/errors.d.ts
generated
vendored
Normal file
67
node_modules/swissqrbill/lib/cjs/shared/errors.d.ts
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/** A {@link ValidationError} is thrown when the data provided to swissqrbill is invalid. */
|
||||
export declare class ValidationError extends Error {
|
||||
/** A stable error code that can be used to identify the error programmatically. */
|
||||
code: keyof typeof ValidationErrors;
|
||||
}
|
||||
export declare enum ValidationErrors {
|
||||
ACCOUNT_IS_QR_IBAN_BUT_REFERENCE_IS_MISSING = "If there is no reference, a conventional IBAN must be used.",
|
||||
ACCOUNT_IS_QR_IBAN_BUT_REFERENCE_IS_REGULAR = "QR-IBAN requires the use of a QR-Reference.",
|
||||
ACCOUNT_IS_REGULAR_IBAN_BUT_REFERENCE_IS_QR = "QR-Reference requires the use of a QR-IBAN.",
|
||||
ACCOUNT_LENGTH_IS_INVALID = "The provided IBAN number '{iban}' is either too long or too short.",
|
||||
ADDITIONAL_INFORMATION_LENGTH_IS_INVALID = "Additional information must be a maximum of 140 characters.",
|
||||
ADDITIONAL_INFORMATION_TYPE_IS_INVALID = "Additional information must be a string.",
|
||||
ALTERNATIVE_SCHEME_LENGTH_IS_INVALID = "{scheme} must be a maximum of 100 characters.",
|
||||
ALTERNATIVE_SCHEME_TYPE_IS_INVALID = "{scheme} must be a string.",
|
||||
AMOUNT_LENGTH_IS_INVALID = "Amount must be a maximum of 12 digits.",
|
||||
AMOUNT_TYPE_IS_INVALID = "Amount must be a number.",
|
||||
CREDITOR_ACCOUNT_COUNTRY_IS_INVALID = "Only CH and LI IBAN numbers are allowed.",
|
||||
CREDITOR_ACCOUNT_IS_INVALID = "The provided IBAN number '{iban}' is not valid.",
|
||||
CREDITOR_ACCOUNT_IS_UNDEFINED = "Creditor account cannot be undefined.",
|
||||
CREDITOR_ADDRESS_IS_UNDEFINED = "Creditor address cannot be undefined.",
|
||||
CREDITOR_ADDRESS_LENGTH_IS_INVALID = "Creditor address must be a maximum of 70 characters.",
|
||||
CREDITOR_ADDRESS_TYPE_IS_INVALID = "Creditor address TYPE must be a string.",
|
||||
CREDITOR_BUILDING_NUMBER_LENGTH_IS_INVALID = "Creditor buildingNumber must be a maximum of 16 characters.",
|
||||
CREDITOR_BUILDING_NUMBER_TYPE_IS_INVALID = "Creditor buildingNumber must be either a string or a number.",
|
||||
CREDITOR_CITY_IS_UNDEFINED = "Creditor city cannot be undefined.",
|
||||
CREDITOR_CITY_LENGTH_IS_INVALID = "Creditor city must be a maximum of 35 characters.",
|
||||
CREDITOR_CITY_TYPE_IS_INVALID = "Creditor city must be a string.",
|
||||
CREDITOR_COUNTRY_IS_UNDEFINED = "Creditor country cannot be undefined.",
|
||||
CREDITOR_COUNTRY_LENGTH_IS_INVALID = "Creditor country must be 2 characters.",
|
||||
CREDITOR_COUNTRY_TYPE_IS_INVALID = "Creditor country must be a string.",
|
||||
CREDITOR_IS_UNDEFINED = "Creditor cannot be undefined.",
|
||||
CREDITOR_NAME_IS_UNDEFINED = "Creditor name cannot be undefined.",
|
||||
CREDITOR_NAME_LENGTH_IS_INVALID = "Creditor name must be a maximum of 70 characters.",
|
||||
CREDITOR_NAME_TYPE_IS_INVALID = "Creditor name must be a string.",
|
||||
CREDITOR_ZIP_IS_UNDEFINED = "Creditor zip cannot be undefined.",
|
||||
CREDITOR_ZIP_LENGTH_IS_INVALID = "Creditor zip must be a maximum of 16 characters.",
|
||||
CREDITOR_ZIP_TYPE_IS_INVALID = "Creditor zip must be either a string or a number.",
|
||||
CURRENCY_IS_UNDEFINED = "Currency cannot be undefined.",
|
||||
CURRENCY_LENGTH_IS_INVALID = "Currency must be a length of 3 characters.",
|
||||
CURRENCY_STRING_IS_INVALID = "Currency must be either 'CHF' or 'EUR'",
|
||||
CURRENCY_TYPE_IS_INVALID = "Currency must be a string.",
|
||||
DEBTOR_ADDRESS_IS_UNDEFINED = "Debtor address cannot be undefined.",
|
||||
DEBTOR_ADDRESS_LENGTH_IS_INVALID = "Debtor address must be a maximum of 70 characters.",
|
||||
DEBTOR_ADDRESS_TYPE_IS_INVALID = "Debtor address TYPE must be a string.",
|
||||
DEBTOR_BUILDING_NUMBER_LENGTH_IS_INVALID = "Debtor buildingNumber must be a maximum of 16 characters.",
|
||||
DEBTOR_BUILDING_NUMBER_TYPE_IS_INVALID = "Debtor buildingNumber must be either a string or a number.",
|
||||
DEBTOR_CITY_IS_UNDEFINED = "Debtor city cannot be undefined.",
|
||||
DEBTOR_CITY_LENGTH_IS_INVALID = "Debtor city must be a maximum of 35 characters.",
|
||||
DEBTOR_CITY_TYPE_IS_INVALID = "Debtor city must be a string.",
|
||||
DEBTOR_COUNTRY_IS_UNDEFINED = "Debtor country cannot be undefined.",
|
||||
DEBTOR_COUNTRY_LENGTH_IS_INVALID = "Debtor country must be 2 characters.",
|
||||
DEBTOR_COUNTRY_TYPE_IS_INVALID = "Debtor country must be a string.",
|
||||
DEBTOR_IS_UNDEFINED = "Debtor cannot be undefined.",
|
||||
DEBTOR_NAME_IS_UNDEFINED = "Debtor name cannot be undefined.",
|
||||
DEBTOR_NAME_LENGTH_IS_INVALID = "Debtor name must be a maximum of 70 characters.",
|
||||
DEBTOR_NAME_TYPE_IS_INVALID = "Debtor name must be a string.",
|
||||
DEBTOR_ZIP_IS_UNDEFINED = "Debtor zip cannot be undefined.",
|
||||
DEBTOR_ZIP_LENGTH_IS_INVALID = "Debtor zip must be a maximum of 16 characters.",
|
||||
DEBTOR_ZIP_TYPE_IS_INVALID = "Debtor zip must be either a string or a number.",
|
||||
MESSAGE_AND_ADDITIONAL_INFORMATION_LENGTH_IS_INVALID = "Message and additionalInformation combined must be a maximum of 140 characters.",
|
||||
MESSAGE_LENGTH_IS_INVALID = "Message must be a maximum of 140 characters.",
|
||||
MESSAGE_TYPE_IS_INVALID = "Message must be a string.",
|
||||
QR_REFERENCE_IS_INVALID = "The provided QR-Reference '{reference}' is not valid.",
|
||||
QR_REFERENCE_LENGTH_IS_INVALID = "QR-Reference must be a must be exactly 27 characters.",
|
||||
REFERENCE_TYPE_IS_INVALID = "Reference must be a string.",
|
||||
REGULAR_REFERENCE_LENGTH_IS_INVALID = "Creditor reference must be a maximum of 25 characters."
|
||||
}
|
||||
700
node_modules/swissqrbill/lib/cjs/shared/qr-code-generator.cjs
generated
vendored
Normal file
700
node_modules/swissqrbill/lib/cjs/shared/qr-code-generator.cjs
generated
vendored
Normal file
@@ -0,0 +1,700 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
exports.qrcodegen = void 0;
|
||||
((qrcodegen2) => {
|
||||
const _QrCode = class _QrCode {
|
||||
/*-- Constructor (low level) and fields --*/
|
||||
// Creates a new QR Code with the given version number,
|
||||
// error correction level, data codeword bytes, and mask number.
|
||||
// This is a low-level API that most users should not use directly.
|
||||
// A mid-level API is the encodeSegments() function.
|
||||
constructor(version, errorCorrectionLevel, dataCodewords, msk) {
|
||||
this.version = version;
|
||||
this.errorCorrectionLevel = errorCorrectionLevel;
|
||||
this.modules = [];
|
||||
this.isFunction = [];
|
||||
if (version < _QrCode.MIN_VERSION || version > _QrCode.MAX_VERSION)
|
||||
throw "Version value out of range";
|
||||
if (msk < -1 || msk > 7)
|
||||
throw "Mask value out of range";
|
||||
this.size = version * 4 + 17;
|
||||
const row = [];
|
||||
for (let i = 0; i < this.size; i++)
|
||||
row.push(false);
|
||||
for (let i = 0; i < this.size; i++) {
|
||||
this.modules.push(row.slice());
|
||||
this.isFunction.push(row.slice());
|
||||
}
|
||||
this.drawFunctionPatterns();
|
||||
const allCodewords = this.addEccAndInterleave(dataCodewords);
|
||||
this.drawCodewords(allCodewords);
|
||||
if (msk == -1) {
|
||||
let minPenalty = 1e9;
|
||||
for (let i = 0; i < 8; i++) {
|
||||
this.applyMask(i);
|
||||
this.drawFormatBits(i);
|
||||
const penalty = this.getPenaltyScore();
|
||||
if (penalty < minPenalty) {
|
||||
msk = i;
|
||||
minPenalty = penalty;
|
||||
}
|
||||
this.applyMask(i);
|
||||
}
|
||||
}
|
||||
assert(0 <= msk && msk <= 7);
|
||||
this.mask = msk;
|
||||
this.applyMask(msk);
|
||||
this.drawFormatBits(msk);
|
||||
this.isFunction = [];
|
||||
}
|
||||
/*-- Static factory functions (high level) --*/
|
||||
// Returns a QR Code representing the given Unicode text string at the given error correction level.
|
||||
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
|
||||
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
|
||||
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
||||
// ecl argument if it can be done without increasing the version.
|
||||
static encodeText(text, ecl) {
|
||||
const segs = qrcodegen2.QrSegment.makeSegments(text);
|
||||
return _QrCode.encodeSegments(segs, ecl);
|
||||
}
|
||||
// Returns a QR Code representing the given binary data at the given error correction level.
|
||||
// This function always encodes using the binary segment mode, not any text mode. The maximum number of
|
||||
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
||||
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
||||
static encodeBinary(data, ecl) {
|
||||
const seg = qrcodegen2.QrSegment.makeBytes(data);
|
||||
return _QrCode.encodeSegments([seg], ecl);
|
||||
}
|
||||
/*-- Static factory functions (mid level) --*/
|
||||
// Returns a QR Code representing the given segments with the given encoding parameters.
|
||||
// The smallest possible QR Code version within the given range is automatically
|
||||
// chosen for the output. Iff boostEcl is true, then the ECC level of the result
|
||||
// may be higher than the ecl argument if it can be done without increasing the
|
||||
// version. The mask number is either between 0 to 7 (inclusive) to force that
|
||||
// mask, or -1 to automatically choose an appropriate mask (which may be slow).
|
||||
// This function allows the user to create a custom sequence of segments that switches
|
||||
// between modes (such as alphanumeric and byte) to encode text in less space.
|
||||
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
||||
static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
|
||||
if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7)
|
||||
throw "Invalid value";
|
||||
let version;
|
||||
let dataUsedBits;
|
||||
for (version = minVersion; ; version++) {
|
||||
const dataCapacityBits2 = _QrCode.getNumDataCodewords(version, ecl) * 8;
|
||||
const usedBits = QrSegment.getTotalBits(segs, version);
|
||||
if (usedBits <= dataCapacityBits2) {
|
||||
dataUsedBits = usedBits;
|
||||
break;
|
||||
}
|
||||
if (version >= maxVersion)
|
||||
throw "Data too long";
|
||||
}
|
||||
for (const newEcl of [_QrCode.Ecc.MEDIUM, _QrCode.Ecc.QUARTILE, _QrCode.Ecc.HIGH]) {
|
||||
if (boostEcl && dataUsedBits <= _QrCode.getNumDataCodewords(version, newEcl) * 8)
|
||||
ecl = newEcl;
|
||||
}
|
||||
const bb = [];
|
||||
for (const seg of segs) {
|
||||
appendBits(seg.mode.modeBits, 4, bb);
|
||||
appendBits(seg.numChars, seg.mode.numCharCountBits(version), bb);
|
||||
for (const b of seg.getData())
|
||||
bb.push(b);
|
||||
}
|
||||
assert(bb.length == dataUsedBits);
|
||||
const dataCapacityBits = _QrCode.getNumDataCodewords(version, ecl) * 8;
|
||||
assert(bb.length <= dataCapacityBits);
|
||||
appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
|
||||
appendBits(0, (8 - bb.length % 8) % 8, bb);
|
||||
assert(bb.length % 8 == 0);
|
||||
for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)
|
||||
appendBits(padByte, 8, bb);
|
||||
const dataCodewords = [];
|
||||
while (dataCodewords.length * 8 < bb.length)
|
||||
dataCodewords.push(0);
|
||||
bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
|
||||
return new _QrCode(version, ecl, dataCodewords, mask);
|
||||
}
|
||||
/*-- Accessor methods --*/
|
||||
// Returns the color of the module (pixel) at the given coordinates, which is false
|
||||
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
||||
// If the given coordinates are out of bounds, then false (light) is returned.
|
||||
getModule(x, y) {
|
||||
return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];
|
||||
}
|
||||
/*-- Private helper methods for constructor: Drawing function modules --*/
|
||||
// Reads this object's version field, and draws and marks all function modules.
|
||||
drawFunctionPatterns() {
|
||||
for (let i = 0; i < this.size; i++) {
|
||||
this.setFunctionModule(6, i, i % 2 == 0);
|
||||
this.setFunctionModule(i, 6, i % 2 == 0);
|
||||
}
|
||||
this.drawFinderPattern(3, 3);
|
||||
this.drawFinderPattern(this.size - 4, 3);
|
||||
this.drawFinderPattern(3, this.size - 4);
|
||||
const alignPatPos = this.getAlignmentPatternPositions();
|
||||
const numAlign = alignPatPos.length;
|
||||
for (let i = 0; i < numAlign; i++) {
|
||||
for (let j = 0; j < numAlign; j++) {
|
||||
if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0))
|
||||
this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
|
||||
}
|
||||
}
|
||||
this.drawFormatBits(0);
|
||||
this.drawVersion();
|
||||
}
|
||||
// Draws two copies of the format bits (with its own error correction code)
|
||||
// based on the given mask and this object's error correction level field.
|
||||
drawFormatBits(mask) {
|
||||
const data = this.errorCorrectionLevel.formatBits << 3 | mask;
|
||||
let rem = data;
|
||||
for (let i = 0; i < 10; i++)
|
||||
rem = rem << 1 ^ (rem >>> 9) * 1335;
|
||||
const bits = (data << 10 | rem) ^ 21522;
|
||||
assert(bits >>> 15 == 0);
|
||||
for (let i = 0; i <= 5; i++)
|
||||
this.setFunctionModule(8, i, getBit(bits, i));
|
||||
this.setFunctionModule(8, 7, getBit(bits, 6));
|
||||
this.setFunctionModule(8, 8, getBit(bits, 7));
|
||||
this.setFunctionModule(7, 8, getBit(bits, 8));
|
||||
for (let i = 9; i < 15; i++)
|
||||
this.setFunctionModule(14 - i, 8, getBit(bits, i));
|
||||
for (let i = 0; i < 8; i++)
|
||||
this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
|
||||
for (let i = 8; i < 15; i++)
|
||||
this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
|
||||
this.setFunctionModule(8, this.size - 8, true);
|
||||
}
|
||||
// Draws two copies of the version bits (with its own error correction code),
|
||||
// based on this object's version field, iff 7 <= version <= 40.
|
||||
drawVersion() {
|
||||
if (this.version < 7)
|
||||
return;
|
||||
let rem = this.version;
|
||||
for (let i = 0; i < 12; i++)
|
||||
rem = rem << 1 ^ (rem >>> 11) * 7973;
|
||||
const bits = this.version << 12 | rem;
|
||||
assert(bits >>> 18 == 0);
|
||||
for (let i = 0; i < 18; i++) {
|
||||
const color = getBit(bits, i);
|
||||
const a = this.size - 11 + i % 3;
|
||||
const b = Math.floor(i / 3);
|
||||
this.setFunctionModule(a, b, color);
|
||||
this.setFunctionModule(b, a, color);
|
||||
}
|
||||
}
|
||||
// Draws a 9*9 finder pattern including the border separator,
|
||||
// with the center module at (x, y). Modules can be out of bounds.
|
||||
drawFinderPattern(x, y) {
|
||||
for (let dy = -4; dy <= 4; dy++) {
|
||||
for (let dx = -4; dx <= 4; dx++) {
|
||||
const dist = Math.max(Math.abs(dx), Math.abs(dy));
|
||||
const xx = x + dx;
|
||||
const yy = y + dy;
|
||||
if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)
|
||||
this.setFunctionModule(xx, yy, dist != 2 && dist != 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Draws a 5*5 alignment pattern, with the center module
|
||||
// at (x, y). All modules must be in bounds.
|
||||
drawAlignmentPattern(x, y) {
|
||||
for (let dy = -2; dy <= 2; dy++) {
|
||||
for (let dx = -2; dx <= 2; dx++)
|
||||
this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1);
|
||||
}
|
||||
}
|
||||
// Sets the color of a module and marks it as a function module.
|
||||
// Only used by the constructor. Coordinates must be in bounds.
|
||||
setFunctionModule(x, y, isDark) {
|
||||
this.modules[y][x] = isDark;
|
||||
this.isFunction[y][x] = true;
|
||||
}
|
||||
/*-- Private helper methods for constructor: Codewords and masking --*/
|
||||
// Returns a new byte string representing the given data with the appropriate error correction
|
||||
// codewords appended to it, based on this object's version and error correction level.
|
||||
addEccAndInterleave(data) {
|
||||
const ver = this.version;
|
||||
const ecl = this.errorCorrectionLevel;
|
||||
if (data.length != _QrCode.getNumDataCodewords(ver, ecl))
|
||||
throw "Invalid argument";
|
||||
const numBlocks = _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
||||
const blockEccLen = _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
|
||||
const rawCodewords = Math.floor(_QrCode.getNumRawDataModules(ver) / 8);
|
||||
const numShortBlocks = numBlocks - rawCodewords % numBlocks;
|
||||
const shortBlockLen = Math.floor(rawCodewords / numBlocks);
|
||||
const blocks = [];
|
||||
const rsDiv = _QrCode.reedSolomonComputeDivisor(blockEccLen);
|
||||
for (let i = 0, k = 0; i < numBlocks; i++) {
|
||||
const dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
|
||||
k += dat.length;
|
||||
const ecc = _QrCode.reedSolomonComputeRemainder(dat, rsDiv);
|
||||
if (i < numShortBlocks)
|
||||
dat.push(0);
|
||||
blocks.push(dat.concat(ecc));
|
||||
}
|
||||
const result = [];
|
||||
for (let i = 0; i < blocks[0].length; i++) {
|
||||
blocks.forEach((block, j) => {
|
||||
if (i != shortBlockLen - blockEccLen || j >= numShortBlocks)
|
||||
result.push(block[i]);
|
||||
});
|
||||
}
|
||||
assert(result.length == rawCodewords);
|
||||
return result;
|
||||
}
|
||||
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
||||
// data area of this QR Code. Function modules need to be marked off before this is called.
|
||||
drawCodewords(data) {
|
||||
if (data.length != Math.floor(_QrCode.getNumRawDataModules(this.version) / 8))
|
||||
throw "Invalid argument";
|
||||
let i = 0;
|
||||
for (let right = this.size - 1; right >= 1; right -= 2) {
|
||||
if (right == 6)
|
||||
right = 5;
|
||||
for (let vert = 0; vert < this.size; vert++) {
|
||||
for (let j = 0; j < 2; j++) {
|
||||
const x = right - j;
|
||||
const upward = (right + 1 & 2) == 0;
|
||||
const y = upward ? this.size - 1 - vert : vert;
|
||||
if (!this.isFunction[y][x] && i < data.length * 8) {
|
||||
this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(i == data.length * 8);
|
||||
}
|
||||
// XORs the codeword modules in this QR Code with the given mask pattern.
|
||||
// The function modules must be marked and the codeword bits must be drawn
|
||||
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
||||
// the same mask value a second time will undo the mask. A final well-formed
|
||||
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
||||
applyMask(mask) {
|
||||
if (mask < 0 || mask > 7)
|
||||
throw "Mask value out of range";
|
||||
for (let y = 0; y < this.size; y++) {
|
||||
for (let x = 0; x < this.size; x++) {
|
||||
let invert;
|
||||
switch (mask) {
|
||||
case 0:
|
||||
invert = (x + y) % 2 == 0;
|
||||
break;
|
||||
case 1:
|
||||
invert = y % 2 == 0;
|
||||
break;
|
||||
case 2:
|
||||
invert = x % 3 == 0;
|
||||
break;
|
||||
case 3:
|
||||
invert = (x + y) % 3 == 0;
|
||||
break;
|
||||
case 4:
|
||||
invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0;
|
||||
break;
|
||||
case 5:
|
||||
invert = x * y % 2 + x * y % 3 == 0;
|
||||
break;
|
||||
case 6:
|
||||
invert = (x * y % 2 + x * y % 3) % 2 == 0;
|
||||
break;
|
||||
case 7:
|
||||
invert = ((x + y) % 2 + x * y % 3) % 2 == 0;
|
||||
break;
|
||||
default:
|
||||
throw "Unreachable";
|
||||
}
|
||||
if (!this.isFunction[y][x] && invert)
|
||||
this.modules[y][x] = !this.modules[y][x];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
||||
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
||||
getPenaltyScore() {
|
||||
let result = 0;
|
||||
for (let y = 0; y < this.size; y++) {
|
||||
let runColor = false;
|
||||
let runX = 0;
|
||||
const runHistory = [0, 0, 0, 0, 0, 0, 0];
|
||||
for (let x = 0; x < this.size; x++) {
|
||||
if (this.modules[y][x] == runColor) {
|
||||
runX++;
|
||||
if (runX == 5)
|
||||
result += _QrCode.PENALTY_N1;
|
||||
else if (runX > 5)
|
||||
result++;
|
||||
} else {
|
||||
this.finderPenaltyAddHistory(runX, runHistory);
|
||||
if (!runColor)
|
||||
result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;
|
||||
runColor = this.modules[y][x];
|
||||
runX = 1;
|
||||
}
|
||||
}
|
||||
result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode.PENALTY_N3;
|
||||
}
|
||||
for (let x = 0; x < this.size; x++) {
|
||||
let runColor = false;
|
||||
let runY = 0;
|
||||
const runHistory = [0, 0, 0, 0, 0, 0, 0];
|
||||
for (let y = 0; y < this.size; y++) {
|
||||
if (this.modules[y][x] == runColor) {
|
||||
runY++;
|
||||
if (runY == 5)
|
||||
result += _QrCode.PENALTY_N1;
|
||||
else if (runY > 5)
|
||||
result++;
|
||||
} else {
|
||||
this.finderPenaltyAddHistory(runY, runHistory);
|
||||
if (!runColor)
|
||||
result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3;
|
||||
runColor = this.modules[y][x];
|
||||
runY = 1;
|
||||
}
|
||||
}
|
||||
result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode.PENALTY_N3;
|
||||
}
|
||||
for (let y = 0; y < this.size - 1; y++) {
|
||||
for (let x = 0; x < this.size - 1; x++) {
|
||||
const color = this.modules[y][x];
|
||||
if (color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1])
|
||||
result += _QrCode.PENALTY_N2;
|
||||
}
|
||||
}
|
||||
let dark = 0;
|
||||
for (const row of this.modules)
|
||||
dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
|
||||
const total = this.size * this.size;
|
||||
const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
|
||||
assert(0 <= k && k <= 9);
|
||||
result += k * _QrCode.PENALTY_N4;
|
||||
assert(0 <= result && result <= 2568888);
|
||||
return result;
|
||||
}
|
||||
/*-- Private helper functions --*/
|
||||
// Returns an ascending list of positions of alignment patterns for this version number.
|
||||
// Each position is in the range [0,177), and are used on both the x and y axes.
|
||||
// This could be implemented as lookup table of 40 variable-length lists of integers.
|
||||
getAlignmentPatternPositions() {
|
||||
if (this.version == 1)
|
||||
return [];
|
||||
else {
|
||||
const numAlign = Math.floor(this.version / 7) + 2;
|
||||
const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
|
||||
const result = [6];
|
||||
for (let pos = this.size - 7; result.length < numAlign; pos -= step)
|
||||
result.splice(1, 0, pos);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
||||
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
||||
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
||||
static getNumRawDataModules(ver) {
|
||||
if (ver < _QrCode.MIN_VERSION || ver > _QrCode.MAX_VERSION)
|
||||
throw "Version number out of range";
|
||||
let result = (16 * ver + 128) * ver + 64;
|
||||
if (ver >= 2) {
|
||||
const numAlign = Math.floor(ver / 7) + 2;
|
||||
result -= (25 * numAlign - 10) * numAlign - 55;
|
||||
if (ver >= 7)
|
||||
result -= 36;
|
||||
}
|
||||
assert(208 <= result && result <= 29648);
|
||||
return result;
|
||||
}
|
||||
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
||||
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
||||
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
|
||||
static getNumDataCodewords(ver, ecl) {
|
||||
return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
||||
}
|
||||
// Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
|
||||
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
|
||||
static reedSolomonComputeDivisor(degree) {
|
||||
if (degree < 1 || degree > 255)
|
||||
throw "Degree out of range";
|
||||
const result = [];
|
||||
for (let i = 0; i < degree - 1; i++)
|
||||
result.push(0);
|
||||
result.push(1);
|
||||
let root = 1;
|
||||
for (let i = 0; i < degree; i++) {
|
||||
for (let j = 0; j < result.length; j++) {
|
||||
result[j] = _QrCode.reedSolomonMultiply(result[j], root);
|
||||
if (j + 1 < result.length)
|
||||
result[j] ^= result[j + 1];
|
||||
}
|
||||
root = _QrCode.reedSolomonMultiply(root, 2);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
||||
static reedSolomonComputeRemainder(data, divisor) {
|
||||
const result = divisor.map((_) => 0);
|
||||
for (const b of data) {
|
||||
const factor = b ^ result.shift();
|
||||
result.push(0);
|
||||
divisor.forEach((coef, i) => result[i] ^= _QrCode.reedSolomonMultiply(coef, factor));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
|
||||
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
|
||||
static reedSolomonMultiply(x, y) {
|
||||
if (x >>> 8 != 0 || y >>> 8 != 0)
|
||||
throw "Byte out of range";
|
||||
let z = 0;
|
||||
for (let i = 7; i >= 0; i--) {
|
||||
z = z << 1 ^ (z >>> 7) * 285;
|
||||
z ^= (y >>> i & 1) * x;
|
||||
}
|
||||
assert(z >>> 8 == 0);
|
||||
return z;
|
||||
}
|
||||
// Can only be called immediately after a light run is added, and
|
||||
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
||||
finderPenaltyCountPatterns(runHistory) {
|
||||
const n = runHistory[1];
|
||||
assert(n <= this.size * 3);
|
||||
const core = n > 0 && runHistory[2] == n && runHistory[3] == n * 3 && runHistory[4] == n && runHistory[5] == n;
|
||||
return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
|
||||
}
|
||||
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
||||
finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
|
||||
if (currentRunColor) {
|
||||
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
||||
currentRunLength = 0;
|
||||
}
|
||||
currentRunLength += this.size;
|
||||
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
||||
return this.finderPenaltyCountPatterns(runHistory);
|
||||
}
|
||||
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
||||
finderPenaltyAddHistory(currentRunLength, runHistory) {
|
||||
if (runHistory[0] == 0)
|
||||
currentRunLength += this.size;
|
||||
runHistory.pop();
|
||||
runHistory.unshift(currentRunLength);
|
||||
}
|
||||
};
|
||||
_QrCode.MIN_VERSION = 1;
|
||||
_QrCode.MAX_VERSION = 40;
|
||||
_QrCode.PENALTY_N1 = 3;
|
||||
_QrCode.PENALTY_N2 = 3;
|
||||
_QrCode.PENALTY_N3 = 40;
|
||||
_QrCode.PENALTY_N4 = 10;
|
||||
_QrCode.ECC_CODEWORDS_PER_BLOCK = [
|
||||
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
||||
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
||||
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
||||
// Low
|
||||
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
||||
// Medium
|
||||
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
||||
// Quartile
|
||||
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
||||
// High
|
||||
];
|
||||
_QrCode.NUM_ERROR_CORRECTION_BLOCKS = [
|
||||
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
||||
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
||||
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
||||
// Low
|
||||
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
||||
// Medium
|
||||
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
||||
// Quartile
|
||||
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
|
||||
// High
|
||||
];
|
||||
let QrCode = _QrCode;
|
||||
qrcodegen2.QrCode = QrCode;
|
||||
function appendBits(val, len, bb) {
|
||||
if (len < 0 || len > 31 || val >>> len != 0)
|
||||
throw "Value out of range";
|
||||
for (let i = len - 1; i >= 0; i--)
|
||||
bb.push(val >>> i & 1);
|
||||
}
|
||||
function getBit(x, i) {
|
||||
return (x >>> i & 1) != 0;
|
||||
}
|
||||
function assert(cond) {
|
||||
if (!cond)
|
||||
throw "Assertion error";
|
||||
}
|
||||
const _QrSegment = class _QrSegment {
|
||||
/*-- Constructor (low level) and fields --*/
|
||||
// Creates a new QR Code segment with the given attributes and data.
|
||||
// The character count (numChars) must agree with the mode and the bit buffer length,
|
||||
// but the constraint isn't checked. The given bit buffer is cloned and stored.
|
||||
constructor(mode, numChars, bitData) {
|
||||
this.mode = mode;
|
||||
this.numChars = numChars;
|
||||
this.bitData = bitData;
|
||||
if (numChars < 0)
|
||||
throw "Invalid argument";
|
||||
this.bitData = bitData.slice();
|
||||
}
|
||||
/*-- Static factory functions (mid level) --*/
|
||||
// Returns a segment representing the given binary data encoded in
|
||||
// byte mode. All input byte arrays are acceptable. Any text string
|
||||
// can be converted to UTF-8 bytes and encoded as a byte mode segment.
|
||||
static makeBytes(data) {
|
||||
const bb = [];
|
||||
for (const b of data)
|
||||
appendBits(b, 8, bb);
|
||||
return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb);
|
||||
}
|
||||
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
||||
static makeNumeric(digits) {
|
||||
if (!_QrSegment.isNumeric(digits))
|
||||
throw "String contains non-numeric characters";
|
||||
const bb = [];
|
||||
for (let i = 0; i < digits.length; ) {
|
||||
const n = Math.min(digits.length - i, 3);
|
||||
appendBits(parseInt(digits.substr(i, n), 10), n * 3 + 1, bb);
|
||||
i += n;
|
||||
}
|
||||
return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb);
|
||||
}
|
||||
// Returns a segment representing the given text string encoded in alphanumeric mode.
|
||||
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
||||
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
||||
static makeAlphanumeric(text) {
|
||||
if (!_QrSegment.isAlphanumeric(text))
|
||||
throw "String contains unencodable characters in alphanumeric mode";
|
||||
const bb = [];
|
||||
let i;
|
||||
for (i = 0; i + 2 <= text.length; i += 2) {
|
||||
let temp = _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
|
||||
temp += _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
|
||||
appendBits(temp, 11, bb);
|
||||
}
|
||||
if (i < text.length)
|
||||
appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
|
||||
return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text.length, bb);
|
||||
}
|
||||
// Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
||||
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
||||
static makeSegments(text) {
|
||||
if (text == "")
|
||||
return [];
|
||||
else if (_QrSegment.isNumeric(text))
|
||||
return [_QrSegment.makeNumeric(text)];
|
||||
else if (_QrSegment.isAlphanumeric(text))
|
||||
return [_QrSegment.makeAlphanumeric(text)];
|
||||
else
|
||||
return [_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text))];
|
||||
}
|
||||
// Returns a segment representing an Extended Channel Interpretation
|
||||
// (ECI) designator with the given assignment value.
|
||||
static makeEci(assignVal) {
|
||||
const bb = [];
|
||||
if (assignVal < 0)
|
||||
throw "ECI assignment value out of range";
|
||||
else if (assignVal < 1 << 7)
|
||||
appendBits(assignVal, 8, bb);
|
||||
else if (assignVal < 1 << 14) {
|
||||
appendBits(2, 2, bb);
|
||||
appendBits(assignVal, 14, bb);
|
||||
} else if (assignVal < 1e6) {
|
||||
appendBits(6, 3, bb);
|
||||
appendBits(assignVal, 21, bb);
|
||||
} else
|
||||
throw "ECI assignment value out of range";
|
||||
return new _QrSegment(_QrSegment.Mode.ECI, 0, bb);
|
||||
}
|
||||
// Tests whether the given string can be encoded as a segment in numeric mode.
|
||||
// A string is encodable iff each character is in the range 0 to 9.
|
||||
static isNumeric(text) {
|
||||
return _QrSegment.NUMERIC_REGEX.test(text);
|
||||
}
|
||||
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
||||
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
||||
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
||||
static isAlphanumeric(text) {
|
||||
return _QrSegment.ALPHANUMERIC_REGEX.test(text);
|
||||
}
|
||||
/*-- Methods --*/
|
||||
// Returns a new copy of the data bits of this segment.
|
||||
getData() {
|
||||
return this.bitData.slice();
|
||||
}
|
||||
// (Package-private) Calculates and returns the number of bits needed to encode the given segments at
|
||||
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
||||
static getTotalBits(segs, version) {
|
||||
let result = 0;
|
||||
for (const seg of segs) {
|
||||
const ccbits = seg.mode.numCharCountBits(version);
|
||||
if (seg.numChars >= 1 << ccbits)
|
||||
return Infinity;
|
||||
result += 4 + ccbits + seg.bitData.length;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Returns a new array of bytes representing the given string encoded in UTF-8.
|
||||
static toUtf8ByteArray(str) {
|
||||
str = encodeURI(str);
|
||||
const result = [];
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
if (str.charAt(i) != "%")
|
||||
result.push(str.charCodeAt(i));
|
||||
else {
|
||||
result.push(parseInt(str.substr(i + 1, 2), 16));
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
_QrSegment.NUMERIC_REGEX = /^[0-9]*$/;
|
||||
_QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/;
|
||||
_QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
||||
let QrSegment = _QrSegment;
|
||||
qrcodegen2.QrSegment = QrSegment;
|
||||
})(exports.qrcodegen || (exports.qrcodegen = {}));
|
||||
((qrcodegen2) => {
|
||||
((QrCode2) => {
|
||||
const _Ecc = class _Ecc {
|
||||
// The QR Code can tolerate about 30% erroneous codewords
|
||||
/*-- Constructor and fields --*/
|
||||
constructor(ordinal, formatBits) {
|
||||
this.ordinal = ordinal;
|
||||
this.formatBits = formatBits;
|
||||
}
|
||||
};
|
||||
_Ecc.LOW = new _Ecc(0, 1);
|
||||
_Ecc.MEDIUM = new _Ecc(1, 0);
|
||||
_Ecc.QUARTILE = new _Ecc(2, 3);
|
||||
_Ecc.HIGH = new _Ecc(3, 2);
|
||||
let Ecc = _Ecc;
|
||||
QrCode2.Ecc = Ecc;
|
||||
})(qrcodegen2.QrCode || (qrcodegen2.QrCode = {}));
|
||||
})(exports.qrcodegen || (exports.qrcodegen = {}));
|
||||
((qrcodegen2) => {
|
||||
((QrSegment2) => {
|
||||
const _Mode = class _Mode {
|
||||
/*-- Constructor and fields --*/
|
||||
constructor(modeBits, numBitsCharCount) {
|
||||
this.modeBits = modeBits;
|
||||
this.numBitsCharCount = numBitsCharCount;
|
||||
}
|
||||
/*-- Method --*/
|
||||
// (Package-private) Returns the bit width of the character count field for a segment in
|
||||
// this mode in a QR Code at the given version number. The result is in the range [0, 16].
|
||||
numCharCountBits(ver) {
|
||||
return this.numBitsCharCount[Math.floor((ver + 7) / 17)];
|
||||
}
|
||||
};
|
||||
_Mode.NUMERIC = new _Mode(1, [10, 12, 14]);
|
||||
_Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]);
|
||||
_Mode.BYTE = new _Mode(4, [8, 16, 16]);
|
||||
_Mode.KANJI = new _Mode(8, [8, 10, 12]);
|
||||
_Mode.ECI = new _Mode(7, [0, 0, 0]);
|
||||
let Mode = _Mode;
|
||||
QrSegment2.Mode = Mode;
|
||||
})(qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {}));
|
||||
})(exports.qrcodegen || (exports.qrcodegen = {}));
|
||||
93
node_modules/swissqrbill/lib/cjs/shared/qr-code-generator.d.ts
generated
vendored
Normal file
93
node_modules/swissqrbill/lib/cjs/shared/qr-code-generator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
export declare namespace qrcodegen {
|
||||
type bit = number;
|
||||
type byte = number;
|
||||
type int = number;
|
||||
export class QrCode {
|
||||
readonly version: int;
|
||||
readonly errorCorrectionLevel: QrCode.Ecc;
|
||||
static encodeText(text: string, ecl: QrCode.Ecc): QrCode;
|
||||
static encodeBinary(data: Readonly<Array<byte>>, ecl: QrCode.Ecc): QrCode;
|
||||
static encodeSegments(segs: Readonly<Array<QrSegment>>, ecl: QrCode.Ecc, minVersion?: int, maxVersion?: int, mask?: int, boostEcl?: boolean): QrCode;
|
||||
readonly size: int;
|
||||
readonly mask: int;
|
||||
private readonly modules;
|
||||
private readonly isFunction;
|
||||
constructor(version: int, errorCorrectionLevel: QrCode.Ecc, dataCodewords: Readonly<Array<byte>>, msk: int);
|
||||
getModule(x: int, y: int): 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: int;
|
||||
static readonly MAX_VERSION: int;
|
||||
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;
|
||||
}
|
||||
export class QrSegment {
|
||||
readonly mode: QrSegment.Mode;
|
||||
readonly numChars: int;
|
||||
private readonly bitData;
|
||||
static makeBytes(data: Readonly<Array<byte>>): QrSegment;
|
||||
static makeNumeric(digits: string): QrSegment;
|
||||
static makeAlphanumeric(text: string): QrSegment;
|
||||
static makeSegments(text: string): Array<QrSegment>;
|
||||
static makeEci(assignVal: int): QrSegment;
|
||||
static isNumeric(text: string): boolean;
|
||||
static isAlphanumeric(text: string): boolean;
|
||||
constructor(mode: QrSegment.Mode, numChars: int, bitData: Array<bit>);
|
||||
getData(): Array<bit>;
|
||||
static getTotalBits(segs: Readonly<Array<QrSegment>>, version: int): number;
|
||||
private static toUtf8ByteArray;
|
||||
private static readonly NUMERIC_REGEX;
|
||||
private static readonly ALPHANUMERIC_REGEX;
|
||||
private static readonly ALPHANUMERIC_CHARSET;
|
||||
}
|
||||
export {};
|
||||
}
|
||||
export declare namespace qrcodegen.QrCode {
|
||||
type int = number;
|
||||
export class Ecc {
|
||||
readonly ordinal: int;
|
||||
readonly formatBits: int;
|
||||
static readonly LOW: Ecc;
|
||||
static readonly MEDIUM: Ecc;
|
||||
static readonly QUARTILE: Ecc;
|
||||
static readonly HIGH: Ecc;
|
||||
private constructor();
|
||||
}
|
||||
export {};
|
||||
}
|
||||
export declare namespace qrcodegen.QrSegment {
|
||||
type int = number;
|
||||
export class Mode {
|
||||
readonly modeBits: int;
|
||||
private readonly numBitsCharCount;
|
||||
static readonly NUMERIC: Mode;
|
||||
static readonly ALPHANUMERIC: Mode;
|
||||
static readonly BYTE: Mode;
|
||||
static readonly KANJI: Mode;
|
||||
static readonly ECI: Mode;
|
||||
private constructor();
|
||||
numCharCountBits(ver: int): int;
|
||||
}
|
||||
export {};
|
||||
}
|
||||
155
node_modules/swissqrbill/lib/cjs/shared/qr-code.cjs
generated
vendored
Normal file
155
node_modules/swissqrbill/lib/cjs/shared/qr-code.cjs
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const cleaner = require("./cleaner.cjs");
|
||||
const qrCodeGenerator = require("./qr-code-generator.cjs");
|
||||
const validator = require("./validator.cjs");
|
||||
const utils = require("./utils.cjs");
|
||||
function generateQRData(data) {
|
||||
var _a, _b, _c, _d, _e, _f;
|
||||
const cleanedData = cleaner.cleanData(data);
|
||||
validator.validateData(cleanedData);
|
||||
const amount = (_a = cleanedData.amount) == null ? void 0 : _a.toFixed(2);
|
||||
const reference = utils.getReferenceType(cleanedData.reference);
|
||||
const qrData = [
|
||||
"SPC",
|
||||
// Swiss Payments Code
|
||||
"0200",
|
||||
// Version
|
||||
"1",
|
||||
// Coding Type UTF-8
|
||||
(_b = cleanedData.creditor.account) != null ? _b : "",
|
||||
// IBAN
|
||||
"S",
|
||||
// Address Type
|
||||
cleanedData.creditor.name,
|
||||
// Name
|
||||
cleanedData.creditor.address,
|
||||
// Address
|
||||
cleanedData.creditor.buildingNumber ? `${cleanedData.creditor.buildingNumber}` : "",
|
||||
`${cleanedData.creditor.zip}`,
|
||||
// Zip
|
||||
cleanedData.creditor.city,
|
||||
// City
|
||||
cleanedData.creditor.country,
|
||||
// Country
|
||||
"",
|
||||
// 1x Empty
|
||||
"",
|
||||
// 2x Empty
|
||||
"",
|
||||
// 3x Empty
|
||||
"",
|
||||
// 4x Empty
|
||||
"",
|
||||
// 5x Empty
|
||||
"",
|
||||
// 6x Empty
|
||||
"",
|
||||
// 7x Empty
|
||||
amount != null ? amount : "",
|
||||
// Amount
|
||||
cleanedData.currency,
|
||||
// Currency
|
||||
...cleanedData.debtor ? [
|
||||
"S",
|
||||
// Address Type
|
||||
cleanedData.debtor.name,
|
||||
// Name
|
||||
cleanedData.debtor.address,
|
||||
// Address
|
||||
cleanedData.debtor.buildingNumber ? `${cleanedData.debtor.buildingNumber}` : "",
|
||||
`${cleanedData.debtor.zip}`,
|
||||
// Zip
|
||||
cleanedData.debtor.city,
|
||||
// City
|
||||
(_c = cleanedData.debtor.country) != null ? _c : ""
|
||||
// Country
|
||||
] : [
|
||||
"",
|
||||
// Empty address type
|
||||
"",
|
||||
// Empty name
|
||||
"",
|
||||
// Empty address
|
||||
"",
|
||||
// Empty building number
|
||||
"",
|
||||
// Empty zip field
|
||||
"",
|
||||
// Empty city field
|
||||
""
|
||||
// Empty country
|
||||
],
|
||||
reference,
|
||||
// Reference type
|
||||
(_d = cleanedData.reference) != null ? _d : "",
|
||||
// Reference
|
||||
(_e = cleanedData.message) != null ? _e : "",
|
||||
// Unstructured message
|
||||
"EPD",
|
||||
// End of payment data
|
||||
(_f = cleanedData.additionalInformation) != null ? _f : "",
|
||||
// Additional information
|
||||
...cleanedData.av1 ? [
|
||||
cleanedData.av1
|
||||
] : [],
|
||||
...cleanedData.av2 ? [
|
||||
cleanedData.av2
|
||||
] : []
|
||||
];
|
||||
return qrData.join("\n");
|
||||
}
|
||||
function renderQRCode(data, size, renderBlockFunction) {
|
||||
const qrData = generateQRData(data);
|
||||
const eci = qrCodeGenerator.qrcodegen.QrSegment.makeEci(26);
|
||||
const segments = qrCodeGenerator.qrcodegen.QrSegment.makeSegments(qrData);
|
||||
const qrCode = qrCodeGenerator.qrcodegen.QrCode.encodeSegments([eci, ...segments], qrCodeGenerator.qrcodegen.QrCode.Ecc.MEDIUM, 10, 25);
|
||||
const blockSize = size / qrCode.size;
|
||||
for (let x = 0; x < qrCode.size; x++) {
|
||||
const xPos = x * blockSize;
|
||||
for (let y = 0; y < qrCode.size; y++) {
|
||||
const yPos = y * blockSize;
|
||||
if (qrCode.getModule(x, y)) {
|
||||
renderBlockFunction(xPos, yPos, blockSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function renderSwissCross(size, renderRectFunction) {
|
||||
const scale = size / utils.mm2pt(46);
|
||||
const swissCrossWhiteBackgroundSize = utils.mm2pt(7) * scale;
|
||||
const swissCrossBlackBackgroundSize = utils.mm2pt(6) * scale;
|
||||
const swissCrossThickness = utils.mm2pt(1.17) * scale;
|
||||
const swissCrossLength = utils.mm2pt(3.89) * scale;
|
||||
renderRectFunction(
|
||||
size / 2 - swissCrossWhiteBackgroundSize / 2,
|
||||
size / 2 - swissCrossWhiteBackgroundSize / 2,
|
||||
swissCrossWhiteBackgroundSize,
|
||||
swissCrossWhiteBackgroundSize,
|
||||
"white"
|
||||
);
|
||||
renderRectFunction(
|
||||
size / 2 - swissCrossBlackBackgroundSize / 2,
|
||||
size / 2 - swissCrossBlackBackgroundSize / 2,
|
||||
swissCrossBlackBackgroundSize,
|
||||
swissCrossBlackBackgroundSize,
|
||||
"black"
|
||||
);
|
||||
renderRectFunction(
|
||||
size / 2 - swissCrossLength / 2,
|
||||
size / 2 - swissCrossThickness / 2,
|
||||
swissCrossLength,
|
||||
swissCrossThickness,
|
||||
"white"
|
||||
);
|
||||
renderRectFunction(
|
||||
size / 2 - swissCrossThickness / 2,
|
||||
size / 2 - swissCrossLength / 2,
|
||||
swissCrossThickness,
|
||||
swissCrossLength,
|
||||
"white"
|
||||
);
|
||||
}
|
||||
exports.generateQRData = generateQRData;
|
||||
exports.renderQRCode = renderQRCode;
|
||||
exports.renderSwissCross = renderSwissCross;
|
||||
4
node_modules/swissqrbill/lib/cjs/shared/qr-code.d.ts
generated
vendored
Normal file
4
node_modules/swissqrbill/lib/cjs/shared/qr-code.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Data } from './types.js';
|
||||
export declare function generateQRData(data: Data): string;
|
||||
export declare function renderQRCode(data: Data, size: number, renderBlockFunction: (x: number, y: number, blockSize: number) => void): void;
|
||||
export declare function renderSwissCross(size: number, renderRectFunction: (x: number, y: number, width: number, height: number, fillColor: string) => void): void;
|
||||
61
node_modules/swissqrbill/lib/cjs/shared/translations.cjs
generated
vendored
Normal file
61
node_modules/swissqrbill/lib/cjs/shared/translations.cjs
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const translations = {
|
||||
DE: {
|
||||
acceptancePoint: "Annahmestelle",
|
||||
account: "Konto / Zahlbar an",
|
||||
additionalInformation: "Zusätzliche Informationen",
|
||||
amount: "Betrag",
|
||||
currency: "Währung",
|
||||
inFavourOf: "Zugunsten",
|
||||
payableBy: "Zahlbar durch",
|
||||
payableByName: "Zahlbar durch (Name/Adresse)",
|
||||
paymentPart: "Zahlteil",
|
||||
receipt: "Empfangsschein",
|
||||
reference: "Referenz",
|
||||
separate: "Vor der Einzahlung abzutrennen"
|
||||
},
|
||||
EN: {
|
||||
acceptancePoint: "Acceptance point",
|
||||
account: "Account / Payable to",
|
||||
additionalInformation: "Additional information",
|
||||
amount: "Amount",
|
||||
currency: "Currency",
|
||||
inFavourOf: "In favour of",
|
||||
payableBy: "Payable by",
|
||||
payableByName: "Payable by (name/address)",
|
||||
paymentPart: "Payment part",
|
||||
receipt: "Receipt",
|
||||
reference: "Reference",
|
||||
separate: "Separate before paying in"
|
||||
},
|
||||
FR: {
|
||||
acceptancePoint: "Point de dépôt",
|
||||
account: "Compte / Payable à",
|
||||
additionalInformation: "Informations supplémentaires",
|
||||
amount: "Montant",
|
||||
currency: "Monnaie",
|
||||
inFavourOf: "En faveur de",
|
||||
payableBy: "Payable par",
|
||||
payableByName: "Payable par (nom/adresse)",
|
||||
paymentPart: "Section paiement",
|
||||
receipt: "Récépissé",
|
||||
reference: "Référence",
|
||||
separate: "A détacher avant le versement"
|
||||
},
|
||||
IT: {
|
||||
acceptancePoint: "Punto di accettazione",
|
||||
account: "Conto / Pagabile a",
|
||||
additionalInformation: "Informazioni supplementari",
|
||||
amount: "Importo",
|
||||
currency: "Valuta",
|
||||
inFavourOf: "A favore di",
|
||||
payableBy: "Pagabile da",
|
||||
payableByName: "Pagabile da (nome/indirizzo)",
|
||||
paymentPart: "Sezione pagamento",
|
||||
receipt: "Ricevuta",
|
||||
reference: "Riferimento",
|
||||
separate: "Da staccare prima del versamento"
|
||||
}
|
||||
};
|
||||
exports.translations = translations;
|
||||
58
node_modules/swissqrbill/lib/cjs/shared/translations.d.ts
generated
vendored
Normal file
58
node_modules/swissqrbill/lib/cjs/shared/translations.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
export declare const translations: {
|
||||
DE: {
|
||||
acceptancePoint: string;
|
||||
account: string;
|
||||
additionalInformation: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
inFavourOf: string;
|
||||
payableBy: string;
|
||||
payableByName: string;
|
||||
paymentPart: string;
|
||||
receipt: string;
|
||||
reference: string;
|
||||
separate: string;
|
||||
};
|
||||
EN: {
|
||||
acceptancePoint: string;
|
||||
account: string;
|
||||
additionalInformation: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
inFavourOf: string;
|
||||
payableBy: string;
|
||||
payableByName: string;
|
||||
paymentPart: string;
|
||||
receipt: string;
|
||||
reference: string;
|
||||
separate: string;
|
||||
};
|
||||
FR: {
|
||||
acceptancePoint: string;
|
||||
account: string;
|
||||
additionalInformation: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
inFavourOf: string;
|
||||
payableBy: string;
|
||||
payableByName: string;
|
||||
paymentPart: string;
|
||||
receipt: string;
|
||||
reference: string;
|
||||
separate: string;
|
||||
};
|
||||
IT: {
|
||||
acceptancePoint: string;
|
||||
account: string;
|
||||
additionalInformation: string;
|
||||
amount: string;
|
||||
currency: string;
|
||||
inFavourOf: string;
|
||||
payableBy: string;
|
||||
payableByName: string;
|
||||
paymentPart: string;
|
||||
receipt: string;
|
||||
reference: string;
|
||||
separate: string;
|
||||
};
|
||||
};
|
||||
1
node_modules/swissqrbill/lib/cjs/shared/types.cjs
generated
vendored
Normal file
1
node_modules/swissqrbill/lib/cjs/shared/types.cjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";
|
||||
134
node_modules/swissqrbill/lib/cjs/shared/types.d.ts
generated
vendored
Normal file
134
node_modules/swissqrbill/lib/cjs/shared/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
export interface Data {
|
||||
/**
|
||||
* Creditor related data.
|
||||
*/
|
||||
creditor: Creditor;
|
||||
/**
|
||||
* The currency to be used. **3 characters.**.
|
||||
*/
|
||||
currency: "CHF" | "EUR";
|
||||
/**
|
||||
* Additional information. **Max 140 characters.**.
|
||||
*
|
||||
* Bill information contain coded information for automated booking of the payment. The data is not forwarded with the payment.
|
||||
*/
|
||||
additionalInformation?: string;
|
||||
/**
|
||||
* The amount. **Max. 12 digits.**.
|
||||
*/
|
||||
amount?: number;
|
||||
/**
|
||||
* Alternative scheme. **Max. 100 characters.**.
|
||||
*
|
||||
* Parameter character chain of the alternative scheme according to the syntax definition in the [“Alternative scheme” section](https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf).
|
||||
*/
|
||||
av1?: string;
|
||||
/**
|
||||
* Alternative scheme. **Max. 100 characters.**.
|
||||
*
|
||||
* Parameter character chain of the alternative scheme according to the syntax definition in the [“Alternative scheme” section](https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf).
|
||||
*/
|
||||
av2?: string;
|
||||
/**
|
||||
* Debtor related data.
|
||||
*/
|
||||
debtor?: Debtor;
|
||||
/**
|
||||
* A message. **Max. 140 characters.**.
|
||||
*
|
||||
* Message can be used to indicate the payment purpose or for additional textual information about payments with a structured reference.
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* A reference number. **Max 27 characters.**.
|
||||
*
|
||||
* QR-IBAN: Maximum 27 characters. Must be filled if a QR-IBAN is used.
|
||||
* Creditor Reference (ISO 11649): Maximum 25 characters.
|
||||
*/
|
||||
reference?: string;
|
||||
}
|
||||
export interface Debtor {
|
||||
/**
|
||||
* Address. **Max 70 characters.**.
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* City. **Max 35 characters.**.
|
||||
*/
|
||||
city: string;
|
||||
/**
|
||||
* Country code. **2 characters.**.
|
||||
*/
|
||||
country: string;
|
||||
/**
|
||||
* Name. **Max. 70 characters.**.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Postal code. **Max 16 characters.**.
|
||||
*/
|
||||
zip: number | string;
|
||||
/**
|
||||
* Building number. **Max 16 characters.**.
|
||||
*/
|
||||
buildingNumber?: number | string;
|
||||
}
|
||||
export interface Creditor extends Debtor {
|
||||
/**
|
||||
* The IBAN. **21 characters.**.
|
||||
*/
|
||||
account: string;
|
||||
}
|
||||
interface QRBillOptions {
|
||||
/**
|
||||
* Font used for the QR-Bill.
|
||||
* Fonts other than Helvetica must be registered in the PDFKit document. {@link http://pdfkit.org/docs/text.html#fonts}.
|
||||
*
|
||||
* @default 'Helvetica'
|
||||
* @example
|
||||
* ```ts
|
||||
* // Register the font
|
||||
* pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf");
|
||||
* pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf");
|
||||
*
|
||||
* const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" });
|
||||
* ```
|
||||
*/
|
||||
fontName?: "Arial" | "Frutiger" | "Helvetica" | "Liberation Sans";
|
||||
/**
|
||||
* The language with which the bill is rendered.
|
||||
*
|
||||
* @default `DE`
|
||||
*/
|
||||
language?: "DE" | "EN" | "FR" | "IT";
|
||||
/**
|
||||
* Whether you want render the outlines. This option may be disabled if you use perforated paper.
|
||||
*
|
||||
* @default `true`
|
||||
*/
|
||||
outlines?: boolean;
|
||||
/**
|
||||
* Whether you want to show the scissors icons or the text `Separate before paying in`.
|
||||
*
|
||||
* **Warning:** Setting **scissors** to false sets **separate** to true. To disable scissors and separate, you have to set both options to false.
|
||||
*
|
||||
* @default `true`
|
||||
*/
|
||||
scissors?: boolean;
|
||||
}
|
||||
export interface PDFOptions extends QRBillOptions {
|
||||
/**
|
||||
* Whether you want to show the text `Separate before paying in` rather than the scissors icons.
|
||||
*
|
||||
* **Warning:** Setting **separate** to true sets **scissors** to false. To disable scissors and separate, you have to set both options to false.
|
||||
*
|
||||
* @default `false`
|
||||
*/
|
||||
separate?: boolean;
|
||||
}
|
||||
export interface SVGOptions extends QRBillOptions {
|
||||
}
|
||||
export type Language = Exclude<QRBillOptions["language"], undefined>;
|
||||
export type FontName = Exclude<QRBillOptions["fontName"], undefined>;
|
||||
export type Currency = Exclude<Data["currency"], undefined>;
|
||||
export {};
|
||||
172
node_modules/swissqrbill/lib/cjs/shared/utils.cjs
generated
vendored
Normal file
172
node_modules/swissqrbill/lib/cjs/shared/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
function isQRIBAN(iban) {
|
||||
iban = iban.replace(/ /g, "");
|
||||
const QRIID = iban.substring(4, 9);
|
||||
return +QRIID >= 3e4 && +QRIID <= 31999;
|
||||
}
|
||||
function isIBANValid(iban) {
|
||||
iban = iban.replace(/ /g, "").toUpperCase();
|
||||
iban = iban.substring(4) + iban.substring(0, 4);
|
||||
return mod97(iban) === 1;
|
||||
}
|
||||
function formatIBAN(iban) {
|
||||
var _a;
|
||||
const ibanArray = iban.replace(/ /g, "").match(/.{1,4}/g);
|
||||
return (_a = ibanArray == null ? void 0 : ibanArray.join(" ")) != null ? _a : iban;
|
||||
}
|
||||
function isQRReference(reference) {
|
||||
reference = reference.replace(/ /g, "");
|
||||
if (reference.length !== 27) {
|
||||
return false;
|
||||
}
|
||||
if (!/^\d+$/.test(reference)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isQRReferenceValid(reference) {
|
||||
reference = reference.replace(/ /g, "");
|
||||
if (!isQRReference(reference)) {
|
||||
return false;
|
||||
}
|
||||
const ref = reference.substring(0, 26);
|
||||
const checksum = reference.substring(26, 27);
|
||||
const calculatedChecksum = calculateQRReferenceChecksum(ref);
|
||||
return calculatedChecksum === checksum;
|
||||
}
|
||||
function isSCORReference(reference) {
|
||||
reference = reference.replace(/ /g, "").toUpperCase();
|
||||
if (!reference.startsWith("RF")) {
|
||||
return false;
|
||||
}
|
||||
if (reference.length < 5 || reference.length > 25) {
|
||||
return false;
|
||||
}
|
||||
if (!/^[\dA-Z]+$/.test(reference)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isSCORReferenceValid(reference) {
|
||||
reference = reference.replace(/ /g, "");
|
||||
if (!isSCORReference(reference)) {
|
||||
return false;
|
||||
}
|
||||
const ref = reference.substring(4);
|
||||
if (Number.isNaN(reference)) {
|
||||
return false;
|
||||
}
|
||||
const checksum = reference.substring(2, 4);
|
||||
if (Number.isNaN(checksum)) {
|
||||
return false;
|
||||
}
|
||||
const calculatedChecksum = calculateSCORReferenceChecksum(ref);
|
||||
return calculatedChecksum === checksum;
|
||||
}
|
||||
function calculateSCORReferenceChecksum(reference) {
|
||||
reference = reference.replace(/ /g, "");
|
||||
const checksum = 98 - mod97(`${reference}RF00`);
|
||||
return `${checksum}`.padStart(2, "0");
|
||||
}
|
||||
function calculateQRReferenceChecksum(reference) {
|
||||
return mod10(reference);
|
||||
}
|
||||
function formatQRReference(reference) {
|
||||
const trimmedReference = reference.replace(/ /g, "");
|
||||
const match = trimmedReference.substring(2).match(/.{1,5}/g);
|
||||
return match ? `${trimmedReference.substring(0, 2)} ${match.join(" ")}` : reference;
|
||||
}
|
||||
function formatSCORReference(reference) {
|
||||
var _a;
|
||||
const trimmedReference = reference.replace(/ /g, "");
|
||||
const match = trimmedReference.match(/.{1,4}/g);
|
||||
return (_a = match == null ? void 0 : match.join(" ")) != null ? _a : reference;
|
||||
}
|
||||
function formatReference(reference) {
|
||||
const referenceType = getReferenceType(reference);
|
||||
if (referenceType === "QRR") {
|
||||
return formatQRReference(reference);
|
||||
} else if (referenceType === "SCOR") {
|
||||
return formatSCORReference(reference);
|
||||
}
|
||||
return reference;
|
||||
}
|
||||
function formatAmount(amount) {
|
||||
const amountString = amount.toFixed(2);
|
||||
const amountArray = amountString.split(".");
|
||||
let formattedAmountWithoutDecimals = "";
|
||||
for (let x = amountArray[0].length - 1, i = 1; x >= 0; x--, i++) {
|
||||
formattedAmountWithoutDecimals = amountArray[0][x] + formattedAmountWithoutDecimals;
|
||||
if (i === 3) {
|
||||
formattedAmountWithoutDecimals = ` ${formattedAmountWithoutDecimals}`;
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
return `${formattedAmountWithoutDecimals.trim()}.${amountArray[1]}`;
|
||||
}
|
||||
function mm2pt(millimeters) {
|
||||
return millimeters * 2.83465;
|
||||
}
|
||||
function pt2mm(points) {
|
||||
return points / 2.83465;
|
||||
}
|
||||
function mm2px(millimeters) {
|
||||
return millimeters * 960 / 254;
|
||||
}
|
||||
function px2mm(pixels) {
|
||||
return pixels * 254 / 960;
|
||||
}
|
||||
function getReferenceType(reference) {
|
||||
if (typeof reference === "undefined") {
|
||||
return "NON";
|
||||
} else if (isQRReference(reference)) {
|
||||
return "QRR";
|
||||
} else {
|
||||
return "SCOR";
|
||||
}
|
||||
}
|
||||
function mod97(input) {
|
||||
const charCodeOfLetterA = "A".charCodeAt(0);
|
||||
const inputArr = input.split("");
|
||||
for (let i = 0; i < inputArr.length; i++) {
|
||||
const charCode = inputArr[i].charCodeAt(0);
|
||||
if (charCode >= charCodeOfLetterA) {
|
||||
inputArr[i] = `${charCode - charCodeOfLetterA + 10}`;
|
||||
}
|
||||
}
|
||||
input = inputArr.join("");
|
||||
let remainder = 0;
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const digit = +input[i];
|
||||
remainder = (10 * remainder + digit) % 97;
|
||||
}
|
||||
return remainder;
|
||||
}
|
||||
function mod10(input) {
|
||||
const trimmedInput = input.replace(/ /g, "");
|
||||
const table = [0, 9, 4, 6, 8, 2, 7, 1, 3, 5];
|
||||
let carry = 0;
|
||||
for (let i = 0; i < trimmedInput.length; i++) {
|
||||
carry = table[(carry + parseInt(trimmedInput.substring(i, i + 1), 10)) % 10];
|
||||
}
|
||||
return ((10 - carry) % 10).toString();
|
||||
}
|
||||
exports.calculateQRReferenceChecksum = calculateQRReferenceChecksum;
|
||||
exports.calculateSCORReferenceChecksum = calculateSCORReferenceChecksum;
|
||||
exports.formatAmount = formatAmount;
|
||||
exports.formatIBAN = formatIBAN;
|
||||
exports.formatQRReference = formatQRReference;
|
||||
exports.formatReference = formatReference;
|
||||
exports.formatSCORReference = formatSCORReference;
|
||||
exports.getReferenceType = getReferenceType;
|
||||
exports.isIBANValid = isIBANValid;
|
||||
exports.isQRIBAN = isQRIBAN;
|
||||
exports.isQRReference = isQRReference;
|
||||
exports.isQRReferenceValid = isQRReferenceValid;
|
||||
exports.isSCORReference = isSCORReference;
|
||||
exports.isSCORReferenceValid = isSCORReferenceValid;
|
||||
exports.mm2pt = mm2pt;
|
||||
exports.mm2px = mm2px;
|
||||
exports.pt2mm = pt2mm;
|
||||
exports.px2mm = px2mm;
|
||||
128
node_modules/swissqrbill/lib/cjs/shared/utils.d.ts
generated
vendored
Normal file
128
node_modules/swissqrbill/lib/cjs/shared/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Checks whether the given iban is a QR-IBAN or not.
|
||||
*
|
||||
* @param iban The IBAN to be checked.
|
||||
* @returns `true` if the given IBAN is a QR-IBAN and `false` otherwise.
|
||||
*/
|
||||
export declare function isQRIBAN(iban: string): boolean;
|
||||
/**
|
||||
* Validates the given IBAN.
|
||||
*
|
||||
* @param iban The IBAN to be checked.
|
||||
* @returns `true` if the checksum of the given IBAN is valid and `false` otherwise.
|
||||
*/
|
||||
export declare function isIBANValid(iban: string): boolean;
|
||||
/**
|
||||
* Formats the given IBAN according the specifications to be easily readable.
|
||||
*
|
||||
* @param iban The IBAN to be formatted.
|
||||
* @returns The formatted IBAN.
|
||||
*/
|
||||
export declare function formatIBAN(iban: string): string;
|
||||
/**
|
||||
* Checks whether the given reference is a QR-Reference or not.
|
||||
*
|
||||
* @param reference The Reference to be checked.
|
||||
* @returns `true` if the given reference is a QR-Reference and `false` otherwise.
|
||||
* @remarks The QR-Reference is a 27 digits long string containing only digits. The last digit is the checksum.
|
||||
*/
|
||||
export declare function isQRReference(reference: string): boolean;
|
||||
/**
|
||||
* Validates the given QR-Reference.
|
||||
*
|
||||
* @param reference The reference to be checked.
|
||||
* @returns `true` if the given reference is valid and `false` otherwise.
|
||||
*/
|
||||
export declare function isQRReferenceValid(reference: string): boolean;
|
||||
/**
|
||||
* Checks whether the given reference is a SCOR-Reference or not.
|
||||
*
|
||||
* @param reference The Reference to be checked.
|
||||
* @returns `true` if the given reference is a SCOR-Reference and `false` otherwise.
|
||||
* @remarks The SCOR-Reference is an alphanumeric string beginning with 'RF' and containing a 2 digit checksum and a max 21 digits long reference.
|
||||
*/
|
||||
export declare function isSCORReference(reference: string): boolean;
|
||||
/**
|
||||
* Validates the given SCOR-Reference.
|
||||
*
|
||||
* @param reference The reference to be checked.
|
||||
* @returns `true` if the given reference is valid and `false` otherwise.
|
||||
*/
|
||||
export declare function isSCORReferenceValid(reference: string): boolean;
|
||||
/**
|
||||
* Calculates the checksum according to the ISO 11649 standard.
|
||||
*
|
||||
* @param reference The max 21 digits long reference (without the "RF" and the 2 digit checksum) whose checksum should be calculated.
|
||||
* @returns The calculated checksum as 2 digit string.
|
||||
*/
|
||||
export declare function calculateSCORReferenceChecksum(reference: string): string;
|
||||
/**
|
||||
* Calculates the checksum according the specifications.
|
||||
*
|
||||
* @param reference The 26 digits long reference (without the checksum) whose checksum should be calculated.
|
||||
* @returns The calculated checksum.
|
||||
*/
|
||||
export declare function calculateQRReferenceChecksum(reference: string): string;
|
||||
/**
|
||||
* Formats the given QR-Reference according the specifications to be easily readable.
|
||||
*
|
||||
* @param reference The QR-Reference to be formatted.
|
||||
* @returns The formatted QR-Reference.
|
||||
*/
|
||||
export declare function formatQRReference(reference: string): string;
|
||||
/**
|
||||
* Formats the given SCOR-Reference according the specifications to be easily readable.
|
||||
*
|
||||
* @param reference The SCOR-Reference to be formatted.
|
||||
* @returns The formatted SCOR-Reference.
|
||||
*/
|
||||
export declare function formatSCORReference(reference: string): string;
|
||||
/**
|
||||
* Detects the type of the given reference and formats it according the specifications to be easily readable.
|
||||
*
|
||||
* @param reference The reference to be formatted.
|
||||
* @returns The formatted reference.
|
||||
*/
|
||||
export declare function formatReference(reference: string): string;
|
||||
/**
|
||||
* Formats the given amount according the specifications to be easily readable.
|
||||
*
|
||||
* @param amount Containing the amount to be formatted.
|
||||
* @returns The formatted amount.
|
||||
*/
|
||||
export declare function formatAmount(amount: number): string;
|
||||
/**
|
||||
* Converts millimeters to points.
|
||||
*
|
||||
* @param millimeters The millimeters you want to convert to points.
|
||||
* @returns The converted millimeters in points.
|
||||
*/
|
||||
export declare function mm2pt(millimeters: number): number;
|
||||
/**
|
||||
* Converts points to millimeters.
|
||||
*
|
||||
* @param points The points you want to convert to millimeters.
|
||||
* @returns The converted points in millimeters.
|
||||
*/
|
||||
export declare function pt2mm(points: number): number;
|
||||
/**
|
||||
* Converts millimeters to pixels.
|
||||
*
|
||||
* @param millimeters The millimeters you want to convert to pixels.
|
||||
* @returns The converted millimeters in pixels.
|
||||
*/
|
||||
export declare function mm2px(millimeters: number): number;
|
||||
/**
|
||||
* Converts pixels to millimeters.
|
||||
*
|
||||
* @param pixels Containing the pixels you want to convert to millimeters.
|
||||
* @returns The converted pixels in millimeters.
|
||||
*/
|
||||
export declare function px2mm(pixels: number): number;
|
||||
/**
|
||||
* Detects the type of the given reference.
|
||||
*
|
||||
* @param reference The reference to get the type of.
|
||||
* @returns The type of the given reference.
|
||||
*/
|
||||
export declare function getReferenceType(reference: string | undefined): "NON" | "QRR" | "SCOR";
|
||||
216
node_modules/swissqrbill/lib/cjs/shared/validator.cjs
generated
vendored
Normal file
216
node_modules/swissqrbill/lib/cjs/shared/validator.cjs
generated
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const errors = require("./errors.cjs");
|
||||
const utils = require("./utils.cjs");
|
||||
function validateData(data) {
|
||||
if (data.reference !== void 0) {
|
||||
if (typeof data.reference !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.REFERENCE_TYPE_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (data.message !== void 0) {
|
||||
if (typeof data.message !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.MESSAGE_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.message.length > 140) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.MESSAGE_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (data.additionalInformation !== void 0) {
|
||||
if (typeof data.additionalInformation !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ADDITIONAL_INFORMATION_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.additionalInformation.length > 140) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ADDITIONAL_INFORMATION_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (data.message !== void 0 && data.additionalInformation !== void 0) {
|
||||
if (data.additionalInformation.length + data.message.length > 140) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.MESSAGE_AND_ADDITIONAL_INFORMATION_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (data.av1 !== void 0) {
|
||||
if (typeof data.av1 !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ALTERNATIVE_SCHEME_TYPE_IS_INVALID, { scheme: "AV1" });
|
||||
}
|
||||
if (data.av1.length > 100) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ALTERNATIVE_SCHEME_LENGTH_IS_INVALID, { scheme: "AV1" });
|
||||
}
|
||||
}
|
||||
if (data.av2 !== void 0) {
|
||||
if (typeof data.av2 !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ALTERNATIVE_SCHEME_TYPE_IS_INVALID, { scheme: "AV2" });
|
||||
}
|
||||
if (data.av2.length > 100) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ALTERNATIVE_SCHEME_LENGTH_IS_INVALID, { scheme: "AV2" });
|
||||
}
|
||||
}
|
||||
if (data.creditor === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_IS_UNDEFINED);
|
||||
}
|
||||
if (data.creditor.account === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ACCOUNT_IS_UNDEFINED);
|
||||
}
|
||||
if (!data.creditor.account.startsWith("CH") && !data.creditor.account.startsWith("LI")) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ACCOUNT_COUNTRY_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.account.length !== 21) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ACCOUNT_LENGTH_IS_INVALID, { iban: data.creditor.account });
|
||||
}
|
||||
if (data.creditor.name === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_NAME_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.creditor.name !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_NAME_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.name.length > 70) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_NAME_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.address === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ADDRESS_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.creditor.address !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ADDRESS_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.address.length > 70) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ADDRESS_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.buildingNumber !== void 0) {
|
||||
if (typeof data.creditor.buildingNumber !== "string" && typeof data.creditor.buildingNumber !== "number") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_BUILDING_NUMBER_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.buildingNumber.toString().length > 16) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_BUILDING_NUMBER_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (data.creditor.zip === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ZIP_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.creditor.zip !== "string" && typeof data.creditor.zip !== "number") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ZIP_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.zip.toString().length > 16) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ZIP_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.city === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_CITY_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.creditor.city !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_CITY_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.city.length > 35) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_CITY_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.country === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_COUNTRY_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.creditor.country !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_COUNTRY_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.creditor.country.length !== 2) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_COUNTRY_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.amount !== void 0) {
|
||||
if (typeof data.amount !== "number") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.AMOUNT_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.amount.toFixed(2).toString().length > 12) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.AMOUNT_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (data.currency === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CURRENCY_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.currency !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CURRENCY_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.currency.length !== 3) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CURRENCY_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.currency !== "CHF" && data.currency !== "EUR") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CURRENCY_STRING_IS_INVALID);
|
||||
}
|
||||
if (data.debtor !== void 0) {
|
||||
if (data.debtor.name === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_NAME_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.debtor.name !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_NAME_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.name.length > 70) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_NAME_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.address === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_ADDRESS_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.debtor.address !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_ADDRESS_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.address.length > 70) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_ADDRESS_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.buildingNumber !== void 0) {
|
||||
if (typeof data.debtor.buildingNumber !== "string" && typeof data.debtor.buildingNumber !== "number") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_BUILDING_NUMBER_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.buildingNumber.toString().length > 16) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_BUILDING_NUMBER_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (data.debtor.zip === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_ZIP_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.debtor.zip !== "string" && typeof data.debtor.zip !== "number") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_ZIP_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.zip.toString().length > 16) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_ZIP_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.city === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_CITY_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.debtor.city !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_CITY_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.city.length > 35) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_CITY_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.country === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_COUNTRY_IS_UNDEFINED);
|
||||
}
|
||||
if (typeof data.debtor.country !== "string") {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_COUNTRY_TYPE_IS_INVALID);
|
||||
}
|
||||
if (data.debtor.country.length !== 2) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.DEBTOR_COUNTRY_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
if (utils.isIBANValid(data.creditor.account) === false) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.CREDITOR_ACCOUNT_IS_INVALID, { iban: data.creditor.account });
|
||||
}
|
||||
if (utils.isQRIBAN(data.creditor.account)) {
|
||||
if (data.reference === void 0) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ACCOUNT_IS_QR_IBAN_BUT_REFERENCE_IS_MISSING);
|
||||
}
|
||||
if (data.reference.length !== 27) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.QR_REFERENCE_LENGTH_IS_INVALID);
|
||||
}
|
||||
if (utils.isQRReference(data.reference)) {
|
||||
if (!utils.isQRReferenceValid(data.reference)) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.QR_REFERENCE_IS_INVALID, { reference: data.reference });
|
||||
}
|
||||
} else {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ACCOUNT_IS_QR_IBAN_BUT_REFERENCE_IS_REGULAR);
|
||||
}
|
||||
} else {
|
||||
if (data.reference !== void 0) {
|
||||
if (utils.isQRReference(data.reference)) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.ACCOUNT_IS_REGULAR_IBAN_BUT_REFERENCE_IS_QR);
|
||||
}
|
||||
if (data.reference.length > 25) {
|
||||
throw new errors.ValidationError(errors.ValidationErrors.REGULAR_REFERENCE_LENGTH_IS_INVALID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.validateData = validateData;
|
||||
8
node_modules/swissqrbill/lib/cjs/shared/validator.d.ts
generated
vendored
Normal file
8
node_modules/swissqrbill/lib/cjs/shared/validator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Data } from './types.js';
|
||||
/**
|
||||
* Validate the provided data.
|
||||
*
|
||||
* @param data The data to validate.
|
||||
* @throws { ValidationError } If the data is invalid.
|
||||
*/
|
||||
export declare function validateData(data: Data): void;
|
||||
402
node_modules/swissqrbill/lib/cjs/svg/character-width.cjs
generated
vendored
Normal file
402
node_modules/swissqrbill/lib/cjs/svg/character-width.cjs
generated
vendored
Normal file
@@ -0,0 +1,402 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const arial8pt = {
|
||||
100: 6.11767578125,
|
||||
101: 6.11767578125,
|
||||
102: 3.05615234375,
|
||||
103: 6.11767578125,
|
||||
104: 6.11767578125,
|
||||
105: 2.44384765625,
|
||||
106: 2.44384765625,
|
||||
107: 5.5,
|
||||
108: 2.44384765625,
|
||||
109: 9.1630859375,
|
||||
110: 6.11767578125,
|
||||
111: 6.11767578125,
|
||||
112: 6.11767578125,
|
||||
113: 6.11767578125,
|
||||
114: 3.6630859375,
|
||||
115: 5.5,
|
||||
116: 3.05615234375,
|
||||
117: 6.11767578125,
|
||||
118: 5.5,
|
||||
119: 7.94384765625,
|
||||
120: 5.5,
|
||||
121: 5.5,
|
||||
122: 5.5,
|
||||
123: 3.673828125,
|
||||
124: 2.857421875,
|
||||
125: 3.673828125,
|
||||
126: 6.423828125,
|
||||
160: 3.05615234375,
|
||||
161: 3.6630859375,
|
||||
162: 6.11767578125,
|
||||
163: 6.11767578125,
|
||||
164: 6.11767578125,
|
||||
165: 6.11767578125,
|
||||
166: 2.857421875,
|
||||
167: 6.11767578125,
|
||||
168: 3.6630859375,
|
||||
169: 8.10498046875,
|
||||
170: 4.0712890625,
|
||||
171: 6.11767578125,
|
||||
172: 6.423828125,
|
||||
173: 0,
|
||||
174: 8.10498046875,
|
||||
175: 6.07470703125,
|
||||
176: 4.39892578125,
|
||||
177: 6.037109375,
|
||||
178: 3.6630859375,
|
||||
179: 3.6630859375,
|
||||
180: 3.6630859375,
|
||||
181: 6.337890625,
|
||||
182: 5.908203125,
|
||||
183: 3.6630859375,
|
||||
184: 3.6630859375,
|
||||
185: 3.6630859375,
|
||||
186: 4.017578125,
|
||||
187: 6.11767578125,
|
||||
188: 9.173828125,
|
||||
189: 9.173828125,
|
||||
190: 9.173828125,
|
||||
191: 6.71923828125,
|
||||
192: 7.3369140625,
|
||||
193: 7.3369140625,
|
||||
194: 7.3369140625,
|
||||
195: 7.3369140625,
|
||||
196: 7.3369140625,
|
||||
197: 7.3369140625,
|
||||
198: 11,
|
||||
199: 7.94384765625,
|
||||
200: 7.3369140625,
|
||||
201: 7.3369140625,
|
||||
202: 7.3369140625,
|
||||
203: 7.3369140625,
|
||||
204: 3.05615234375,
|
||||
205: 3.05615234375,
|
||||
206: 3.05615234375,
|
||||
207: 3.05615234375,
|
||||
208: 7.94384765625,
|
||||
209: 7.94384765625,
|
||||
210: 8.55615234375,
|
||||
211: 8.55615234375,
|
||||
212: 8.55615234375,
|
||||
213: 8.55615234375,
|
||||
214: 8.55615234375,
|
||||
215: 6.423828125,
|
||||
216: 8.55615234375,
|
||||
217: 7.94384765625,
|
||||
218: 7.94384765625,
|
||||
219: 7.94384765625,
|
||||
220: 7.94384765625,
|
||||
221: 7.3369140625,
|
||||
222: 7.3369140625,
|
||||
223: 6.71923828125,
|
||||
224: 6.11767578125,
|
||||
225: 6.11767578125,
|
||||
226: 6.11767578125,
|
||||
227: 6.11767578125,
|
||||
228: 6.11767578125,
|
||||
229: 6.11767578125,
|
||||
230: 9.78076171875,
|
||||
231: 5.5,
|
||||
232: 6.11767578125,
|
||||
233: 6.11767578125,
|
||||
234: 6.11767578125,
|
||||
235: 6.11767578125,
|
||||
236: 3.05615234375,
|
||||
237: 3.05615234375,
|
||||
238: 3.05615234375,
|
||||
239: 3.05615234375,
|
||||
240: 6.11767578125,
|
||||
241: 6.11767578125,
|
||||
242: 6.11767578125,
|
||||
243: 6.11767578125,
|
||||
244: 6.11767578125,
|
||||
245: 6.11767578125,
|
||||
246: 6.11767578125,
|
||||
247: 6.037109375,
|
||||
248: 6.71923828125,
|
||||
249: 6.11767578125,
|
||||
250: 6.11767578125,
|
||||
251: 6.11767578125,
|
||||
252: 6.11767578125,
|
||||
253: 5.5,
|
||||
254: 6.11767578125,
|
||||
32: 3.05615234375,
|
||||
33: 3.05615234375,
|
||||
34: 3.90478515625,
|
||||
35: 6.11767578125,
|
||||
36: 6.11767578125,
|
||||
37: 9.78076171875,
|
||||
38: 7.3369140625,
|
||||
39: 2.10009765625,
|
||||
40: 3.6630859375,
|
||||
41: 3.6630859375,
|
||||
42: 4.28076171875,
|
||||
43: 6.423828125,
|
||||
44: 3.05615234375,
|
||||
45: 3.6630859375,
|
||||
46: 3.05615234375,
|
||||
47: 3.05615234375,
|
||||
48: 6.11767578125,
|
||||
49: 6.11767578125,
|
||||
50: 6.11767578125,
|
||||
51: 6.11767578125,
|
||||
52: 6.11767578125,
|
||||
53: 6.11767578125,
|
||||
54: 6.11767578125,
|
||||
55: 6.11767578125,
|
||||
56: 6.11767578125,
|
||||
57: 6.11767578125,
|
||||
58: 3.05615234375,
|
||||
59: 3.05615234375,
|
||||
60: 6.423828125,
|
||||
61: 6.423828125,
|
||||
62: 6.423828125,
|
||||
63: 6.11767578125,
|
||||
64: 11.16650390625,
|
||||
65: 7.3369140625,
|
||||
66: 7.3369140625,
|
||||
67: 7.94384765625,
|
||||
68: 7.94384765625,
|
||||
69: 7.3369140625,
|
||||
70: 6.71923828125,
|
||||
71: 8.55615234375,
|
||||
72: 7.94384765625,
|
||||
73: 3.05615234375,
|
||||
74: 5.5,
|
||||
75: 7.3369140625,
|
||||
76: 6.11767578125,
|
||||
77: 9.1630859375,
|
||||
78: 7.94384765625,
|
||||
79: 8.55615234375,
|
||||
80: 7.3369140625,
|
||||
81: 8.55615234375,
|
||||
82: 7.94384765625,
|
||||
83: 7.3369140625,
|
||||
84: 6.71923828125,
|
||||
85: 7.94384765625,
|
||||
86: 7.3369140625,
|
||||
87: 10.38232421875,
|
||||
88: 7.3369140625,
|
||||
89: 7.3369140625,
|
||||
90: 6.71923828125,
|
||||
91: 3.05615234375,
|
||||
92: 3.05615234375,
|
||||
93: 3.05615234375,
|
||||
94: 5.16162109375,
|
||||
95: 6.11767578125,
|
||||
96: 3.6630859375,
|
||||
97: 6.11767578125,
|
||||
98: 6.11767578125,
|
||||
99: 5.5
|
||||
};
|
||||
const arial10pt = {
|
||||
100: 7.22998046875,
|
||||
101: 7.22998046875,
|
||||
102: 3.61181640625,
|
||||
103: 7.22998046875,
|
||||
104: 7.22998046875,
|
||||
105: 2.88818359375,
|
||||
106: 2.88818359375,
|
||||
107: 6.5,
|
||||
108: 2.88818359375,
|
||||
109: 10.8291015625,
|
||||
110: 7.22998046875,
|
||||
111: 7.22998046875,
|
||||
112: 7.22998046875,
|
||||
113: 7.22998046875,
|
||||
114: 4.3291015625,
|
||||
115: 6.5,
|
||||
116: 3.61181640625,
|
||||
117: 7.22998046875,
|
||||
118: 6.5,
|
||||
119: 9.38818359375,
|
||||
120: 6.5,
|
||||
121: 6.5,
|
||||
122: 6.5,
|
||||
123: 4.341796875,
|
||||
124: 3.376953125,
|
||||
125: 4.341796875,
|
||||
126: 7.591796875,
|
||||
160: 3.61181640625,
|
||||
161: 4.3291015625,
|
||||
162: 7.22998046875,
|
||||
163: 7.22998046875,
|
||||
164: 7.22998046875,
|
||||
165: 7.22998046875,
|
||||
166: 3.376953125,
|
||||
167: 7.22998046875,
|
||||
168: 4.3291015625,
|
||||
169: 9.57861328125,
|
||||
170: 4.8115234375,
|
||||
171: 7.22998046875,
|
||||
172: 7.591796875,
|
||||
173: 0,
|
||||
174: 9.57861328125,
|
||||
175: 7.17919921875,
|
||||
176: 5.19873046875,
|
||||
177: 7.134765625,
|
||||
178: 4.3291015625,
|
||||
179: 4.3291015625,
|
||||
180: 4.3291015625,
|
||||
181: 7.490234375,
|
||||
182: 6.982421875,
|
||||
183: 4.3291015625,
|
||||
184: 4.3291015625,
|
||||
185: 4.3291015625,
|
||||
186: 4.748046875,
|
||||
187: 7.22998046875,
|
||||
188: 10.841796875,
|
||||
189: 10.841796875,
|
||||
190: 10.841796875,
|
||||
191: 7.94091796875,
|
||||
192: 8.6708984375,
|
||||
193: 8.6708984375,
|
||||
194: 8.6708984375,
|
||||
195: 8.6708984375,
|
||||
196: 8.6708984375,
|
||||
197: 8.6708984375,
|
||||
198: 13,
|
||||
199: 9.38818359375,
|
||||
200: 8.6708984375,
|
||||
201: 8.6708984375,
|
||||
202: 8.6708984375,
|
||||
203: 8.6708984375,
|
||||
204: 3.61181640625,
|
||||
205: 3.61181640625,
|
||||
206: 3.61181640625,
|
||||
207: 3.61181640625,
|
||||
208: 9.38818359375,
|
||||
209: 9.38818359375,
|
||||
210: 10.11181640625,
|
||||
211: 10.11181640625,
|
||||
212: 10.11181640625,
|
||||
213: 10.11181640625,
|
||||
214: 10.11181640625,
|
||||
215: 7.591796875,
|
||||
216: 10.11181640625,
|
||||
217: 9.38818359375,
|
||||
218: 9.38818359375,
|
||||
219: 9.38818359375,
|
||||
220: 9.38818359375,
|
||||
221: 8.6708984375,
|
||||
222: 8.6708984375,
|
||||
223: 7.94091796875,
|
||||
224: 7.22998046875,
|
||||
225: 7.22998046875,
|
||||
226: 7.22998046875,
|
||||
227: 7.22998046875,
|
||||
228: 7.22998046875,
|
||||
229: 7.22998046875,
|
||||
230: 11.55908203125,
|
||||
231: 6.5,
|
||||
232: 7.22998046875,
|
||||
233: 7.22998046875,
|
||||
234: 7.22998046875,
|
||||
235: 7.22998046875,
|
||||
236: 3.61181640625,
|
||||
237: 3.61181640625,
|
||||
238: 3.61181640625,
|
||||
239: 3.61181640625,
|
||||
240: 7.22998046875,
|
||||
241: 7.22998046875,
|
||||
242: 7.22998046875,
|
||||
243: 7.22998046875,
|
||||
244: 7.22998046875,
|
||||
245: 7.22998046875,
|
||||
246: 7.22998046875,
|
||||
247: 7.134765625,
|
||||
248: 7.94091796875,
|
||||
249: 7.22998046875,
|
||||
250: 7.22998046875,
|
||||
251: 7.22998046875,
|
||||
252: 7.22998046875,
|
||||
253: 6.5,
|
||||
254: 7.22998046875,
|
||||
32: 3.61181640625,
|
||||
33: 3.61181640625,
|
||||
34: 4.61474609375,
|
||||
35: 7.22998046875,
|
||||
36: 7.22998046875,
|
||||
37: 11.55908203125,
|
||||
38: 8.6708984375,
|
||||
39: 2.48193359375,
|
||||
40: 4.3291015625,
|
||||
41: 4.3291015625,
|
||||
42: 5.05908203125,
|
||||
43: 7.591796875,
|
||||
44: 3.61181640625,
|
||||
45: 4.3291015625,
|
||||
46: 3.61181640625,
|
||||
47: 3.61181640625,
|
||||
48: 7.22998046875,
|
||||
49: 7.22998046875,
|
||||
50: 7.22998046875,
|
||||
51: 7.22998046875,
|
||||
52: 7.22998046875,
|
||||
53: 7.22998046875,
|
||||
54: 7.22998046875,
|
||||
55: 7.22998046875,
|
||||
56: 7.22998046875,
|
||||
57: 7.22998046875,
|
||||
58: 3.61181640625,
|
||||
59: 3.61181640625,
|
||||
60: 7.591796875,
|
||||
61: 7.591796875,
|
||||
62: 7.591796875,
|
||||
63: 7.22998046875,
|
||||
64: 13.19677734375,
|
||||
65: 8.6708984375,
|
||||
66: 8.6708984375,
|
||||
67: 9.38818359375,
|
||||
68: 9.38818359375,
|
||||
69: 8.6708984375,
|
||||
70: 7.94091796875,
|
||||
71: 10.11181640625,
|
||||
72: 9.38818359375,
|
||||
73: 3.61181640625,
|
||||
74: 6.5,
|
||||
75: 8.6708984375,
|
||||
76: 7.22998046875,
|
||||
77: 10.8291015625,
|
||||
78: 9.38818359375,
|
||||
79: 10.11181640625,
|
||||
80: 8.6708984375,
|
||||
81: 10.11181640625,
|
||||
82: 9.38818359375,
|
||||
83: 8.6708984375,
|
||||
84: 7.94091796875,
|
||||
85: 9.38818359375,
|
||||
86: 8.6708984375,
|
||||
87: 12.27001953125,
|
||||
88: 8.6708984375,
|
||||
89: 8.6708984375,
|
||||
90: 7.94091796875,
|
||||
91: 3.61181640625,
|
||||
92: 3.61181640625,
|
||||
93: 3.61181640625,
|
||||
94: 6.10009765625,
|
||||
95: 7.22998046875,
|
||||
96: 4.3291015625,
|
||||
97: 7.22998046875,
|
||||
98: 7.22998046875,
|
||||
99: 6.5
|
||||
};
|
||||
function calculateTextWidth(text, size) {
|
||||
let width = 0;
|
||||
if (size === "8pt") {
|
||||
for (let c = 0; c < text.length; c++) {
|
||||
width += arial8pt[text.charCodeAt(c)];
|
||||
}
|
||||
} else if (size === "10pt") {
|
||||
for (let c = 0; c < text.length; c++) {
|
||||
width += arial10pt[text.charCodeAt(c)];
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
exports.arial10pt = arial10pt;
|
||||
exports.arial8pt = arial8pt;
|
||||
exports.calculateTextWidth = calculateTextWidth;
|
||||
385
node_modules/swissqrbill/lib/cjs/svg/character-width.d.ts
generated
vendored
Normal file
385
node_modules/swissqrbill/lib/cjs/svg/character-width.d.ts
generated
vendored
Normal file
@@ -0,0 +1,385 @@
|
||||
export declare const arial8pt: {
|
||||
100: number;
|
||||
101: number;
|
||||
102: number;
|
||||
103: number;
|
||||
104: number;
|
||||
105: number;
|
||||
106: number;
|
||||
107: number;
|
||||
108: number;
|
||||
109: number;
|
||||
110: number;
|
||||
111: number;
|
||||
112: number;
|
||||
113: number;
|
||||
114: number;
|
||||
115: number;
|
||||
116: number;
|
||||
117: number;
|
||||
118: number;
|
||||
119: number;
|
||||
120: number;
|
||||
121: number;
|
||||
122: number;
|
||||
123: number;
|
||||
124: number;
|
||||
125: number;
|
||||
126: number;
|
||||
160: number;
|
||||
161: number;
|
||||
162: number;
|
||||
163: number;
|
||||
164: number;
|
||||
165: number;
|
||||
166: number;
|
||||
167: number;
|
||||
168: number;
|
||||
169: number;
|
||||
170: number;
|
||||
171: number;
|
||||
172: number;
|
||||
173: number;
|
||||
174: number;
|
||||
175: number;
|
||||
176: number;
|
||||
177: number;
|
||||
178: number;
|
||||
179: number;
|
||||
180: number;
|
||||
181: number;
|
||||
182: number;
|
||||
183: number;
|
||||
184: number;
|
||||
185: number;
|
||||
186: number;
|
||||
187: number;
|
||||
188: number;
|
||||
189: number;
|
||||
190: number;
|
||||
191: number;
|
||||
192: number;
|
||||
193: number;
|
||||
194: number;
|
||||
195: number;
|
||||
196: number;
|
||||
197: number;
|
||||
198: number;
|
||||
199: number;
|
||||
200: number;
|
||||
201: number;
|
||||
202: number;
|
||||
203: number;
|
||||
204: number;
|
||||
205: number;
|
||||
206: number;
|
||||
207: number;
|
||||
208: number;
|
||||
209: number;
|
||||
210: number;
|
||||
211: number;
|
||||
212: number;
|
||||
213: number;
|
||||
214: number;
|
||||
215: number;
|
||||
216: number;
|
||||
217: number;
|
||||
218: number;
|
||||
219: number;
|
||||
220: number;
|
||||
221: number;
|
||||
222: number;
|
||||
223: number;
|
||||
224: number;
|
||||
225: number;
|
||||
226: number;
|
||||
227: number;
|
||||
228: number;
|
||||
229: number;
|
||||
230: number;
|
||||
231: number;
|
||||
232: number;
|
||||
233: number;
|
||||
234: number;
|
||||
235: number;
|
||||
236: number;
|
||||
237: number;
|
||||
238: number;
|
||||
239: number;
|
||||
240: number;
|
||||
241: number;
|
||||
242: number;
|
||||
243: number;
|
||||
244: number;
|
||||
245: number;
|
||||
246: number;
|
||||
247: number;
|
||||
248: number;
|
||||
249: number;
|
||||
250: number;
|
||||
251: number;
|
||||
252: number;
|
||||
253: number;
|
||||
254: number;
|
||||
32: number;
|
||||
33: number;
|
||||
34: number;
|
||||
35: number;
|
||||
36: number;
|
||||
37: number;
|
||||
38: number;
|
||||
39: number;
|
||||
40: number;
|
||||
41: number;
|
||||
42: number;
|
||||
43: number;
|
||||
44: number;
|
||||
45: number;
|
||||
46: number;
|
||||
47: number;
|
||||
48: number;
|
||||
49: number;
|
||||
50: number;
|
||||
51: number;
|
||||
52: number;
|
||||
53: number;
|
||||
54: number;
|
||||
55: number;
|
||||
56: number;
|
||||
57: number;
|
||||
58: number;
|
||||
59: number;
|
||||
60: number;
|
||||
61: number;
|
||||
62: number;
|
||||
63: number;
|
||||
64: number;
|
||||
65: number;
|
||||
66: number;
|
||||
67: number;
|
||||
68: number;
|
||||
69: number;
|
||||
70: number;
|
||||
71: number;
|
||||
72: number;
|
||||
73: number;
|
||||
74: number;
|
||||
75: number;
|
||||
76: number;
|
||||
77: number;
|
||||
78: number;
|
||||
79: number;
|
||||
80: number;
|
||||
81: number;
|
||||
82: number;
|
||||
83: number;
|
||||
84: number;
|
||||
85: number;
|
||||
86: number;
|
||||
87: number;
|
||||
88: number;
|
||||
89: number;
|
||||
90: number;
|
||||
91: number;
|
||||
92: number;
|
||||
93: number;
|
||||
94: number;
|
||||
95: number;
|
||||
96: number;
|
||||
97: number;
|
||||
98: number;
|
||||
99: number;
|
||||
};
|
||||
export declare const arial10pt: {
|
||||
100: number;
|
||||
101: number;
|
||||
102: number;
|
||||
103: number;
|
||||
104: number;
|
||||
105: number;
|
||||
106: number;
|
||||
107: number;
|
||||
108: number;
|
||||
109: number;
|
||||
110: number;
|
||||
111: number;
|
||||
112: number;
|
||||
113: number;
|
||||
114: number;
|
||||
115: number;
|
||||
116: number;
|
||||
117: number;
|
||||
118: number;
|
||||
119: number;
|
||||
120: number;
|
||||
121: number;
|
||||
122: number;
|
||||
123: number;
|
||||
124: number;
|
||||
125: number;
|
||||
126: number;
|
||||
160: number;
|
||||
161: number;
|
||||
162: number;
|
||||
163: number;
|
||||
164: number;
|
||||
165: number;
|
||||
166: number;
|
||||
167: number;
|
||||
168: number;
|
||||
169: number;
|
||||
170: number;
|
||||
171: number;
|
||||
172: number;
|
||||
173: number;
|
||||
174: number;
|
||||
175: number;
|
||||
176: number;
|
||||
177: number;
|
||||
178: number;
|
||||
179: number;
|
||||
180: number;
|
||||
181: number;
|
||||
182: number;
|
||||
183: number;
|
||||
184: number;
|
||||
185: number;
|
||||
186: number;
|
||||
187: number;
|
||||
188: number;
|
||||
189: number;
|
||||
190: number;
|
||||
191: number;
|
||||
192: number;
|
||||
193: number;
|
||||
194: number;
|
||||
195: number;
|
||||
196: number;
|
||||
197: number;
|
||||
198: number;
|
||||
199: number;
|
||||
200: number;
|
||||
201: number;
|
||||
202: number;
|
||||
203: number;
|
||||
204: number;
|
||||
205: number;
|
||||
206: number;
|
||||
207: number;
|
||||
208: number;
|
||||
209: number;
|
||||
210: number;
|
||||
211: number;
|
||||
212: number;
|
||||
213: number;
|
||||
214: number;
|
||||
215: number;
|
||||
216: number;
|
||||
217: number;
|
||||
218: number;
|
||||
219: number;
|
||||
220: number;
|
||||
221: number;
|
||||
222: number;
|
||||
223: number;
|
||||
224: number;
|
||||
225: number;
|
||||
226: number;
|
||||
227: number;
|
||||
228: number;
|
||||
229: number;
|
||||
230: number;
|
||||
231: number;
|
||||
232: number;
|
||||
233: number;
|
||||
234: number;
|
||||
235: number;
|
||||
236: number;
|
||||
237: number;
|
||||
238: number;
|
||||
239: number;
|
||||
240: number;
|
||||
241: number;
|
||||
242: number;
|
||||
243: number;
|
||||
244: number;
|
||||
245: number;
|
||||
246: number;
|
||||
247: number;
|
||||
248: number;
|
||||
249: number;
|
||||
250: number;
|
||||
251: number;
|
||||
252: number;
|
||||
253: number;
|
||||
254: number;
|
||||
32: number;
|
||||
33: number;
|
||||
34: number;
|
||||
35: number;
|
||||
36: number;
|
||||
37: number;
|
||||
38: number;
|
||||
39: number;
|
||||
40: number;
|
||||
41: number;
|
||||
42: number;
|
||||
43: number;
|
||||
44: number;
|
||||
45: number;
|
||||
46: number;
|
||||
47: number;
|
||||
48: number;
|
||||
49: number;
|
||||
50: number;
|
||||
51: number;
|
||||
52: number;
|
||||
53: number;
|
||||
54: number;
|
||||
55: number;
|
||||
56: number;
|
||||
57: number;
|
||||
58: number;
|
||||
59: number;
|
||||
60: number;
|
||||
61: number;
|
||||
62: number;
|
||||
63: number;
|
||||
64: number;
|
||||
65: number;
|
||||
66: number;
|
||||
67: number;
|
||||
68: number;
|
||||
69: number;
|
||||
70: number;
|
||||
71: number;
|
||||
72: number;
|
||||
73: number;
|
||||
74: number;
|
||||
75: number;
|
||||
76: number;
|
||||
77: number;
|
||||
78: number;
|
||||
79: number;
|
||||
80: number;
|
||||
81: number;
|
||||
82: number;
|
||||
83: number;
|
||||
84: number;
|
||||
85: number;
|
||||
86: number;
|
||||
87: number;
|
||||
88: number;
|
||||
89: number;
|
||||
90: number;
|
||||
91: number;
|
||||
92: number;
|
||||
93: number;
|
||||
94: number;
|
||||
95: number;
|
||||
96: number;
|
||||
97: number;
|
||||
98: number;
|
||||
99: number;
|
||||
};
|
||||
export declare function calculateTextWidth(text: string, size: "10pt" | "8pt"): number;
|
||||
6
node_modules/swissqrbill/lib/cjs/svg/index.cjs
generated
vendored
Normal file
6
node_modules/swissqrbill/lib/cjs/svg/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const swissqrbill = require("./swissqrbill.cjs");
|
||||
const swissqrcode = require("./swissqrcode.cjs");
|
||||
exports.SwissQRBill = swissqrbill.SwissQRBill;
|
||||
exports.SwissQRCode = swissqrcode.SwissQRCode;
|
||||
2
node_modules/swissqrbill/lib/cjs/svg/index.d.ts
generated
vendored
Normal file
2
node_modules/swissqrbill/lib/cjs/svg/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './swissqrbill.js';
|
||||
export * from './swissqrcode.js';
|
||||
329
node_modules/swissqrbill/lib/cjs/svg/swissqrbill.cjs
generated
vendored
Normal file
329
node_modules/swissqrbill/lib/cjs/svg/swissqrbill.cjs
generated
vendored
Normal file
@@ -0,0 +1,329 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const svgEngine = require("svg-engine");
|
||||
const cleaner = require("../shared/cleaner.cjs");
|
||||
const translations = require("../shared/translations.cjs");
|
||||
const validator = require("../shared/validator.cjs");
|
||||
const swissqrcode = require("./swissqrcode.cjs");
|
||||
const utils = require("../shared/utils.cjs");
|
||||
const characterWidth = require("./character-width.cjs");
|
||||
class SwissQRBill {
|
||||
constructor(data, options) {
|
||||
this.scissors = true;
|
||||
this.outlines = true;
|
||||
this.language = "DE";
|
||||
this.font = "Arial";
|
||||
this.data = data;
|
||||
this.data = cleaner.cleanData(this.data);
|
||||
validator.validateData(this.data);
|
||||
this.language = (options == null ? void 0 : options.language) !== void 0 ? options.language : this.language;
|
||||
this.outlines = (options == null ? void 0 : options.outlines) !== void 0 ? options.outlines : this.outlines;
|
||||
this.font = (options == null ? void 0 : options.fontName) !== void 0 ? options.fontName : this.font;
|
||||
this.scissors = (options == null ? void 0 : options.scissors) !== void 0 ? options.scissors : this.scissors;
|
||||
this.instance = new svgEngine.SVG();
|
||||
this.instance.width("210mm");
|
||||
this.instance.height("105mm");
|
||||
this._render();
|
||||
}
|
||||
/**
|
||||
* Outputs the SVG as a string.
|
||||
*
|
||||
* @returns The outerHTML of the SVG.
|
||||
*/
|
||||
toString() {
|
||||
return this.instance.outerHTML;
|
||||
}
|
||||
/**
|
||||
* Returns the SVG element.
|
||||
*
|
||||
* @returns The SVG element.
|
||||
*/
|
||||
get element() {
|
||||
return this.instance.element;
|
||||
}
|
||||
_render() {
|
||||
const formattedCreditorAddress = this._formatAddress(this.data.creditor);
|
||||
let receiptLineCount = 0;
|
||||
let paymentPartLineCount = 0;
|
||||
this.instance.addRect(0, 0, "100%", "100%").fill("#fff");
|
||||
if (this.outlines) {
|
||||
this.instance.addLine("62mm", "0mm", "62mm", "105mm").stroke(1, "dashed", "black");
|
||||
}
|
||||
if (this.scissors) {
|
||||
const scissorsCenter = "M8.55299 18.3969C9.54465 17.5748 9.51074 16.0915 9.08357 14.9829L6.47473 8.02261C7.58167 5.9986 7.26467 3.99833 7.80373 3.99833C8.22582 3.99833 8.13259 4.38482 9.23105 4.32719C10.2854 4.27125 11.0652 3.1711 10.9957 2.13197C11.0025 1.09115 10.2041 0.0130391 9.1056 0.00456339C7.99867 -0.0734135 6.96972 0.858918 6.89683 1.95907C6.70527 3.24907 7.48674 5.53413 5.56613 6.60547C4.09305 5.80705 4.08797 4.38991 4.16255 3.10838C4.22358 2.04552 3.91845 0.76738 2.87424 0.260531C1.87241 -0.229367 0.446794 0.25036 0.139972 1.37594C-0.277034 2.51168 0.250156 4.07122 1.55541 4.34244C2.56233 4.55095 3.03528 3.83729 3.40143 4.1119C3.67774 4.31871 3.5167 5.62906 4.566 7.96667L1.908 15.5033C1.64356 16.456 1.65204 17.6206 2.58776 18.463L5.5424 10.6484L8.55299 18.3969ZM10.1634 2.87953C9.55143 3.97629 7.88849 3.88645 7.56641 2.74731C7.20704 1.71666 8.20887 0.397838 9.32767 0.726697C10.2447 0.919943 10.5821 2.12858 10.1634 2.87953ZM3.36753 2.927C2.94544 4.07122 1.00789 3.87797 0.746835 2.71341C0.479001 1.94042 0.8638 0.836881 1.77409 0.758904C2.88102 0.608036 3.87946 1.90821 3.36753 2.927Z";
|
||||
const scissorsSVG = this.instance.addSVG("11px", "19px").x(utils.mm2px(62) - 5.25).y("30pt");
|
||||
scissorsSVG.addPath(scissorsCenter).fill("black");
|
||||
}
|
||||
const receiptContainer = this.instance.addSVG().x("5mm").y("5mm");
|
||||
const receiptTextContainer = receiptContainer.addText();
|
||||
receiptTextContainer.addTSpan(translations.translations[this.language].receipt).x(0).y(0).dy("11pt").fontFamily(this.font).fontWeight("bold").fontSize("11pt");
|
||||
receiptTextContainer.addTSpan(translations.translations[this.language].account).x(0).y("7mm").dy("9pt").fontFamily(this.font).fontWeight("bold").fontSize("6pt");
|
||||
receiptTextContainer.addTSpan(utils.formatIBAN(this.data.creditor.account)).x(0).dy("9pt").fontFamily(this.font).fontWeight("normal").fontSize("8pt");
|
||||
receiptLineCount++;
|
||||
let receiptCreditorAddressLines = [];
|
||||
for (const line of formattedCreditorAddress) {
|
||||
const messageLines = this._fitTextToWidth(line, utils.mm2px(52), 2, "8pt");
|
||||
receiptCreditorAddressLines = [...receiptCreditorAddressLines, ...messageLines];
|
||||
}
|
||||
for (const line of receiptCreditorAddressLines) {
|
||||
receiptLineCount++;
|
||||
receiptTextContainer.addTSpan(line).x(0).dy("9pt").fontFamily(this.font).fontWeight("normal").fontSize("8pt");
|
||||
}
|
||||
if (this.data.reference !== void 0) {
|
||||
receiptTextContainer.addTSpan(translations.translations[this.language].reference).x(0).dy("18pt").fontFamily(this.font).fontWeight("bold").fontSize("6pt");
|
||||
receiptTextContainer.addTSpan(utils.formatReference(this.data.reference)).x(0).dy("9pt").fontFamily(this.font).fontWeight("normal").fontSize("8pt");
|
||||
receiptLineCount++;
|
||||
}
|
||||
if (this.data.debtor !== void 0) {
|
||||
const formattedDebtorAddress = this._formatAddress(this.data.debtor);
|
||||
receiptTextContainer.addTSpan(translations.translations[this.language].payableBy).x(0).dy("18pt").fontFamily(this.font).fontWeight("bold").fontSize("6pt");
|
||||
let receiptDebtorAddressLines = [];
|
||||
for (const line of formattedDebtorAddress) {
|
||||
const messageLines = this._fitTextToWidth(line, utils.mm2px(52), 2, "8pt");
|
||||
receiptDebtorAddressLines = [...receiptDebtorAddressLines, ...messageLines];
|
||||
}
|
||||
for (const line of receiptDebtorAddressLines) {
|
||||
receiptTextContainer.addTSpan(line).x(0).dy("9pt").fontFamily(this.font).fontWeight("normal").fontSize("8pt");
|
||||
}
|
||||
} else {
|
||||
receiptTextContainer.addTSpan(translations.translations[this.language].payableByName).x(0).dy("18pt").fontFamily(this.font).fontWeight("bold").fontSize("6pt");
|
||||
const referenceHeight = this.data.reference !== void 0 ? utils.pt2mm(18) : 0;
|
||||
this._addRectangle(
|
||||
5,
|
||||
12 + utils.pt2mm(9) + receiptLineCount * utils.pt2mm(9) + utils.pt2mm(referenceHeight) + utils.pt2mm(18) + 1,
|
||||
52,
|
||||
20
|
||||
);
|
||||
}
|
||||
const amountContainer = receiptContainer.addText().y("63mm");
|
||||
amountContainer.addTSpan(translations.translations[this.language].currency).x(0).dy("6pt").fontFamily(this.font).fontWeight("bold").fontSize("6pt");
|
||||
const amountXPosition = this.data.amount === void 0 ? 13 : 22;
|
||||
amountContainer.addTSpan(translations.translations[this.language].amount).x(`${amountXPosition}mm`).fontFamily(this.font).fontWeight("bold").fontSize("6pt");
|
||||
amountContainer.addTSpan(this.data.currency).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("8pt");
|
||||
if (this.data.amount !== void 0) {
|
||||
amountContainer.addTSpan(utils.formatAmount(this.data.amount)).x(`${amountXPosition}mm`).fontFamily(this.font).fontWeight("normal").fontSize("8pt");
|
||||
} else {
|
||||
this._addRectangle(27, 68, 30, 10);
|
||||
}
|
||||
amountContainer.addTSpan(translations.translations[this.language].acceptancePoint).x("52mm").y("82mm").textAlign("right").fontFamily(this.font).fontWeight("bold").fontSize("6pt");
|
||||
const paymentPartContainer = this.instance.addSVG().x("67mm").y("5mm");
|
||||
paymentPartContainer.addText(translations.translations[this.language].paymentPart).x(0).y(0).dy("11pt").fontFamily(this.font).fontWeight("bold").fontSize("11pt");
|
||||
this._renderQRCode();
|
||||
const paymentPartMiddleTextContainer = paymentPartContainer.addText().y("63mm");
|
||||
paymentPartMiddleTextContainer.addTSpan(translations.translations[this.language].currency).x(0).dy("8pt").fontFamily(this.font).fontWeight("bold").fontSize("8pt");
|
||||
paymentPartMiddleTextContainer.addTSpan(translations.translations[this.language].amount).x("22mm").fontFamily(this.font).fontWeight("bold").fontSize("8pt");
|
||||
paymentPartMiddleTextContainer.addTSpan(this.data.currency).x(0).dy("13pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
if (this.data.amount !== void 0) {
|
||||
paymentPartMiddleTextContainer.addTSpan(utils.formatAmount(this.data.amount)).x("22mm").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
} else {
|
||||
this._addRectangle(
|
||||
78,
|
||||
68 + utils.pt2mm(8) + utils.pt2mm(5),
|
||||
40,
|
||||
15
|
||||
);
|
||||
}
|
||||
const alternativeSchemeContainer = paymentPartContainer.addText().x(0).y("90mm");
|
||||
if (this.data.av1 !== void 0) {
|
||||
const [scheme, data] = this.data.av1.split(/(\/.+)/);
|
||||
alternativeSchemeContainer.addTSpan(scheme).x(0).fontFamily(this.font).fontWeight("bold").fontSize("7pt");
|
||||
alternativeSchemeContainer.addTSpan(this.data.av1.length > 90 ? `${data.substr(0, 87)}...` : data).fontFamily(this.font).fontWeight("normal").fontSize("7pt");
|
||||
}
|
||||
if (this.data.av2 !== void 0) {
|
||||
const [scheme, data] = this.data.av2.split(/(\/.+)/);
|
||||
alternativeSchemeContainer.addTSpan(scheme).x(0).dy("8pt").fontFamily(this.font).fontWeight("bold").fontSize("7pt");
|
||||
alternativeSchemeContainer.addTSpan(this.data.av2.length > 90 ? `${data.substr(0, 87)}...` : data).fontFamily(this.font).fontWeight("normal").fontSize("7pt");
|
||||
}
|
||||
const paymentPartDebtorContainer = this.instance.addSVG().x("118mm").y("5mm");
|
||||
const paymentPartRightTextContainer = paymentPartDebtorContainer.addText();
|
||||
paymentPartRightTextContainer.addTSpan(translations.translations[this.language].account).x(0).y(0).dy("11pt").fontFamily(this.font).fontWeight("bold").fontSize("8pt");
|
||||
paymentPartRightTextContainer.addTSpan(utils.formatIBAN(this.data.creditor.account)).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
paymentPartLineCount++;
|
||||
let paymentPartCreditorAddressLines = [];
|
||||
for (const line of formattedCreditorAddress) {
|
||||
const messageLines = this._fitTextToWidth(line, utils.mm2px(52), 2, "8pt");
|
||||
paymentPartCreditorAddressLines = [...paymentPartCreditorAddressLines, ...messageLines];
|
||||
}
|
||||
for (const line of paymentPartCreditorAddressLines) {
|
||||
paymentPartRightTextContainer.addTSpan(line).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
paymentPartLineCount++;
|
||||
}
|
||||
if (this.data.reference !== void 0) {
|
||||
paymentPartRightTextContainer.addTSpan(translations.translations[this.language].reference).x(0).dy("22pt").fontFamily(this.font).fontWeight("bold").fontSize("8pt");
|
||||
paymentPartRightTextContainer.addTSpan(utils.formatReference(this.data.reference)).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
paymentPartLineCount++;
|
||||
}
|
||||
if (this.data.message !== void 0 || this.data.additionalInformation !== void 0) {
|
||||
paymentPartRightTextContainer.addTSpan(translations.translations[this.language].additionalInformation).x(0).dy("22pt").fontFamily(this.font).fontWeight("bold").fontSize("8pt");
|
||||
const referenceType = utils.getReferenceType(this.data.reference);
|
||||
const maxLines = referenceType === "QRR" || referenceType === "SCOR" ? 3 : 4;
|
||||
const lengthInPixel = utils.mm2px(87);
|
||||
this._getLineCountOfText(this.data.message, lengthInPixel, "10pt");
|
||||
const linesOfAdditionalInformation = this._getLineCountOfText(this.data.additionalInformation, lengthInPixel, "10pt");
|
||||
if (this.data.additionalInformation !== void 0) {
|
||||
if (referenceType === "QRR" || referenceType === "SCOR") {
|
||||
if (this.data.message !== void 0) {
|
||||
paymentPartRightTextContainer.addTSpan(this._ellipsis(this.data.message, lengthInPixel, "10pt")).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
paymentPartLineCount++;
|
||||
}
|
||||
} else {
|
||||
if (this.data.message !== void 0) {
|
||||
const maxLinesOfMessage = maxLines - linesOfAdditionalInformation;
|
||||
const messageLines = this._fitTextToWidth(this.data.message, lengthInPixel, maxLinesOfMessage, "10pt");
|
||||
for (let i = 0; i < maxLinesOfMessage; i++) {
|
||||
paymentPartRightTextContainer.addTSpan(messageLines[i]).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
paymentPartLineCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
const additionalInformationLines = this._fitTextToWidth(this.data.additionalInformation, lengthInPixel, linesOfAdditionalInformation, "10pt");
|
||||
for (let i = 0; i < linesOfAdditionalInformation; i++) {
|
||||
paymentPartRightTextContainer.addTSpan(additionalInformationLines[i]).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
paymentPartLineCount++;
|
||||
}
|
||||
} else if (this.data.message !== void 0) {
|
||||
const messageLines = this._fitTextToWidth(this.data.message, lengthInPixel, maxLines, "10pt");
|
||||
for (let i = 0; i < maxLines; i++) {
|
||||
paymentPartRightTextContainer.addTSpan(messageLines[i]).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
paymentPartLineCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.data.debtor !== void 0) {
|
||||
const formattedDebtorAddress = this._formatAddress(this.data.debtor);
|
||||
paymentPartRightTextContainer.addTSpan(translations.translations[this.language].payableBy).x(0).dy("22pt").fontFamily(this.font).fontWeight("bold").fontSize("8pt");
|
||||
let paymentPartDebtorAddressLines = [];
|
||||
for (const line of formattedDebtorAddress) {
|
||||
const messageLines = this._fitTextToWidth(line, utils.mm2px(52), 2, "8pt");
|
||||
paymentPartDebtorAddressLines = [...paymentPartDebtorAddressLines, ...messageLines];
|
||||
}
|
||||
for (const line of paymentPartDebtorAddressLines) {
|
||||
paymentPartRightTextContainer.addTSpan(line).x(0).dy("11pt").fontFamily(this.font).fontWeight("normal").fontSize("10pt");
|
||||
}
|
||||
} else {
|
||||
paymentPartRightTextContainer.addTSpan(translations.translations[this.language].payableByName).x(0).dy("22pt").fontFamily(this.font).fontWeight("bold").fontSize("8pt");
|
||||
const referenceHeight = this.data.reference !== void 0 ? utils.pt2mm(22) : 0;
|
||||
const additionalInformationHeight = this.data.additionalInformation !== void 0 || this.data.message !== void 0 ? utils.pt2mm(22) : 0;
|
||||
this._addRectangle(
|
||||
118,
|
||||
5 + utils.pt2mm(11) + paymentPartLineCount * utils.pt2mm(11) + referenceHeight + additionalInformationHeight + utils.pt2mm(22) + 1,
|
||||
65,
|
||||
25
|
||||
);
|
||||
}
|
||||
}
|
||||
_renderQRCode() {
|
||||
const qrCode = new swissqrcode.SwissQRCode(this.data);
|
||||
qrCode.instance.x("67mm").y("17mm");
|
||||
this.instance.appendInstance(qrCode.instance);
|
||||
}
|
||||
_formatAddress(data) {
|
||||
const countryPrefix = data.country !== "CH" ? `${data.country} - ` : "";
|
||||
if (data.buildingNumber !== void 0) {
|
||||
return [data.name, `${data.address} ${data.buildingNumber}`, `${countryPrefix}${data.zip} ${data.city}`];
|
||||
} else {
|
||||
return [data.name, data.address, `${countryPrefix}${data.zip} ${data.city}`];
|
||||
}
|
||||
}
|
||||
_getLineCountOfText(text, lengthInPixel, size) {
|
||||
if (text === void 0) {
|
||||
return 0;
|
||||
} else {
|
||||
let lines = 0;
|
||||
let remainder = characterWidth.calculateTextWidth(text, size);
|
||||
while (remainder > 1) {
|
||||
lines++;
|
||||
remainder -= lengthInPixel;
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
_fitTextToWidth(text, lengthInPixel, maxLines, size) {
|
||||
var _a;
|
||||
const remainder = text.split(/([ |-])/g);
|
||||
let lines = [];
|
||||
let currentLine = "";
|
||||
const checkCurrentLine = (currentLine2) => {
|
||||
const lines2 = [];
|
||||
let leftover = "";
|
||||
if (characterWidth.calculateTextWidth(currentLine2, size) > lengthInPixel) {
|
||||
const currentWordRemainder = currentLine2.split("");
|
||||
let currentWord = "";
|
||||
while (currentWordRemainder.length > 0) {
|
||||
if (characterWidth.calculateTextWidth(currentWord, size) <= lengthInPixel) {
|
||||
currentWord += currentWordRemainder.shift();
|
||||
} else {
|
||||
lines2.push(currentWord);
|
||||
currentWord = "";
|
||||
}
|
||||
}
|
||||
if (currentWord !== "") {
|
||||
leftover = currentWord;
|
||||
}
|
||||
} else {
|
||||
lines2.push(currentLine2);
|
||||
}
|
||||
return { leftover, lines: lines2 };
|
||||
};
|
||||
while (remainder.length > 0) {
|
||||
const nextWord = remainder.shift();
|
||||
const separator = (_a = remainder.shift()) != null ? _a : "";
|
||||
if (characterWidth.calculateTextWidth(currentLine + nextWord + separator, size) <= lengthInPixel) {
|
||||
currentLine += nextWord + separator;
|
||||
} else {
|
||||
if (currentLine !== "") {
|
||||
const { leftover, lines: newLines } = checkCurrentLine(currentLine);
|
||||
lines.push(...newLines);
|
||||
currentLine = leftover + nextWord + separator;
|
||||
} else {
|
||||
currentLine = nextWord + separator;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentLine !== "" && currentLine !== " ") {
|
||||
const { leftover, lines: newLines } = checkCurrentLine(currentLine);
|
||||
lines.push(...newLines);
|
||||
if (leftover !== "") {
|
||||
lines.push(leftover);
|
||||
}
|
||||
}
|
||||
if (lines.length > maxLines) {
|
||||
lines = lines.slice(0, maxLines);
|
||||
lines[lines.length - 1] = this._ellipsis(lines[lines.length - 1], lengthInPixel, size);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
_ellipsis(text, lengthInPixel, size) {
|
||||
let result = "";
|
||||
if (characterWidth.calculateTextWidth(text, size) > lengthInPixel) {
|
||||
for (let c = 0; c < text.length; c++) {
|
||||
if (characterWidth.calculateTextWidth(`${result}${text[c]}...`, size) <= lengthInPixel) {
|
||||
result += text[c];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
if (result.substr(-1) === " ") {
|
||||
result = result.slice(0, -1);
|
||||
}
|
||||
return `${result}...`;
|
||||
}
|
||||
_addRectangle(x, y, width, height) {
|
||||
const container = this.instance.addSVG(`${width}mm`, `${height}mm`);
|
||||
container.x(`${x}mm`).y(`${y}mm`);
|
||||
const length = 3;
|
||||
container.addLine("0mm", "0mm", `${length}mm`, "0mm").stroke(".75pt", "solid", "black");
|
||||
container.addLine(`${width - length}mm`, "0mm", `${width}mm`, "0mm").stroke(".75pt", "solid", "black");
|
||||
container.addLine(`${width}mm`, "0mm", `${width}mm`, `${length}mm`).stroke(".75pt", "solid", "black");
|
||||
container.addLine(`${width}mm`, `${height - length}mm`, `${width}mm`, `${height}mm`).stroke(".75pt", "solid", "black");
|
||||
container.addLine(`${width - length}mm`, `${height}mm`, `${width}mm`, `${height}mm`).stroke(".75pt", "solid", "black");
|
||||
container.addLine("0mm", `${height}mm`, `${length}mm`, `${height}mm`).stroke(".75pt", "solid", "black");
|
||||
container.addLine("0mm", `${height - length}mm`, "0mm", `${height}mm`).stroke(".75pt", "solid", "black");
|
||||
container.addLine("0mm", "0mm", "0mm", `${length}mm`).stroke(".75pt", "solid", "black");
|
||||
return container;
|
||||
}
|
||||
}
|
||||
exports.SwissQRBill = SwissQRBill;
|
||||
62
node_modules/swissqrbill/lib/cjs/svg/swissqrbill.d.ts
generated
vendored
Normal file
62
node_modules/swissqrbill/lib/cjs/svg/swissqrbill.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import { SVG } from 'svg-engine';
|
||||
import { Data, SVGOptions } from '../shared/types.js';
|
||||
/**
|
||||
* The SwissQRBill class creates the Payment Part with the QR Code as an SVG.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const data = {
|
||||
* amount: 1994.75,
|
||||
* creditor: {
|
||||
* account: "CH44 3199 9123 0008 8901 2",
|
||||
* address: "Musterstrasse",
|
||||
* buildingNumber: 7,
|
||||
* city: "Musterstadt",
|
||||
* country: "CH",
|
||||
* name: "SwissQRBill",
|
||||
* zip: 1234
|
||||
* },
|
||||
* currency: "CHF",
|
||||
* debtor: {
|
||||
* address: "Musterstrasse",
|
||||
* buildingNumber: 1,
|
||||
* city: "Musterstadt",
|
||||
* country: "CH",
|
||||
* name: "Peter Muster",
|
||||
* zip: 1234
|
||||
* },
|
||||
* reference: "21 00000 00003 13947 14300 09017"
|
||||
* };
|
||||
*
|
||||
* const svg = new SwissQRBill(data);
|
||||
* writeFileSync("qr-bill.svg", svg.toString());
|
||||
* ```
|
||||
*/
|
||||
export declare class SwissQRBill {
|
||||
instance: SVG;
|
||||
private scissors;
|
||||
private outlines;
|
||||
private language;
|
||||
private font;
|
||||
private data;
|
||||
constructor(data: Data, options?: SVGOptions);
|
||||
/**
|
||||
* Outputs the SVG as a string.
|
||||
*
|
||||
* @returns The outerHTML of the SVG.
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Returns the SVG element.
|
||||
*
|
||||
* @returns The SVG element.
|
||||
*/
|
||||
get element(): SVGElement;
|
||||
private _render;
|
||||
private _renderQRCode;
|
||||
private _formatAddress;
|
||||
private _getLineCountOfText;
|
||||
private _fitTextToWidth;
|
||||
private _ellipsis;
|
||||
private _addRectangle;
|
||||
}
|
||||
51
node_modules/swissqrbill/lib/cjs/svg/swissqrcode.cjs
generated
vendored
Normal file
51
node_modules/swissqrbill/lib/cjs/svg/swissqrcode.cjs
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const svgEngine = require("svg-engine");
|
||||
const qrCode = require("../shared/qr-code.cjs");
|
||||
class SwissQRCode {
|
||||
/**
|
||||
* Creates a Swiss QR Code.
|
||||
*
|
||||
* @param data The data to be encoded in the QR code.
|
||||
* @param size The size of the QR code in mm.
|
||||
* @throws { ValidationError } Throws an error if the data is invalid.
|
||||
*/
|
||||
constructor(data, size = 46) {
|
||||
this.instance = new svgEngine.SVG();
|
||||
this.instance.width(`${size}mm`);
|
||||
this.instance.height(`${size}mm`);
|
||||
qrCode.renderQRCode(data, size, (xPos, yPos, blockSize) => {
|
||||
this.instance.addRect(
|
||||
`${xPos}mm`,
|
||||
`${yPos}mm`,
|
||||
`${blockSize}mm`,
|
||||
`${blockSize}mm`
|
||||
).fill("black");
|
||||
});
|
||||
qrCode.renderSwissCross(size, (xPos, yPos, width, height, fillColor) => {
|
||||
this.instance.addRect(
|
||||
`${xPos}mm`,
|
||||
`${yPos}mm`,
|
||||
`${width}mm`,
|
||||
`${height}mm`
|
||||
).fill(fillColor);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Outputs the SVG as a string.
|
||||
*
|
||||
* @returns The outerHTML of the SVG element.
|
||||
*/
|
||||
toString() {
|
||||
return this.instance.outerHTML;
|
||||
}
|
||||
/**
|
||||
* Returns the SVG element.
|
||||
*
|
||||
* @returns The SVG element.
|
||||
*/
|
||||
get element() {
|
||||
return this.instance.element;
|
||||
}
|
||||
}
|
||||
exports.SwissQRCode = SwissQRCode;
|
||||
25
node_modules/swissqrbill/lib/cjs/svg/swissqrcode.d.ts
generated
vendored
Normal file
25
node_modules/swissqrbill/lib/cjs/svg/swissqrcode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { SVG } from 'svg-engine';
|
||||
import { Data } from '../shared/types.js';
|
||||
export declare class SwissQRCode {
|
||||
instance: SVG;
|
||||
/**
|
||||
* Creates a Swiss QR Code.
|
||||
*
|
||||
* @param data The data to be encoded in the QR code.
|
||||
* @param size The size of the QR code in mm.
|
||||
* @throws { ValidationError } Throws an error if the data is invalid.
|
||||
*/
|
||||
constructor(data: Data, size?: number);
|
||||
/**
|
||||
* Outputs the SVG as a string.
|
||||
*
|
||||
* @returns The outerHTML of the SVG element.
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Returns the SVG element.
|
||||
*
|
||||
* @returns The SVG element.
|
||||
*/
|
||||
get element(): SVGElement;
|
||||
}
|
||||
Reference in New Issue
Block a user