@vkontakte/vk-qr 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/figures.d.ts +9 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +848 -672
- package/dist/index.js.map +1 -1
- package/dist/qr.d.ts +62 -70
- package/dist/qr.d.ts.map +1 -1
- package/dist/svg-path.d.ts +8 -0
- package/dist/svg-path.d.ts.map +1 -0
- package/dist/svg.d.ts +5 -9
- package/dist/svg.d.ts.map +1 -1
- package/dist/types.d.ts +13 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/constants.ts +9 -0
- package/src/figures.ts +106 -0
- package/src/index.ts +16 -10
- package/src/qr.ts +707 -871
- package/src/svg-path.ts +254 -0
- package/src/svg.ts +129 -270
- package/src/types.ts +15 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/svg.ts","../src/qr.ts","../src/index.ts"],"sourcesContent":["import type { QrCode } from './qr.ts';\nimport type { RequiredQrOptions } from './types.ts';\n\nconst MULTI = 1;\nconst QR_BORDER = 7;\nconst TILE_SIZE = 96 * MULTI;\nexport const INC_TILE_SIZE = 96 * MULTI;\nconst SMALL_QR_SIZE = 25;\n\n/**\n * Returns the color of the module (pixel) at the given coordinates, which is false\n * for white or true for black. The top left corner has the coordinates (x=0, y=0).\n * If the given coordinates are out of bounds, then false (white) is returned.\n */\nconst getPixel = (\n x: number,\n y: number,\n size: number,\n modules: boolean[][],\n isLogoShowed: boolean,\n) => {\n if (x < QR_BORDER && y < QR_BORDER) {\n return false;\n }\n\n if (x >= size - QR_BORDER && y < QR_BORDER) {\n return false;\n }\n\n if (x < QR_BORDER && y >= size - QR_BORDER) {\n return false;\n }\n\n if (isLogoShowed) {\n let imageTiles = QR_BORDER + 2;\n if (size <= SMALL_QR_SIZE) {\n imageTiles--;\n }\n\n let paddingTiles = (size - QR_BORDER * 2 - imageTiles) / 2 - 1;\n if (size <= SMALL_QR_SIZE) {\n paddingTiles++;\n }\n\n if (\n x > QR_BORDER + paddingTiles &&\n x < size - QR_BORDER - paddingTiles - 1 &&\n y > QR_BORDER + paddingTiles &&\n y < size - QR_BORDER - paddingTiles - 1\n ) {\n return false;\n }\n\n return 0 <= x && x < size && 0 <= y && y < size && modules[y][x];\n }\n\n return modules[y]?.[x];\n};\n\nconst getNeighbors = (\n x: number,\n y: number,\n size: number,\n modules: boolean[][],\n isLogoShowed = true,\n) => ({\n l: getPixel(x - 1, y, size, modules, isLogoShowed),\n r: getPixel(x + 1, y, size, modules, isLogoShowed),\n t: getPixel(x, y - 1, size, modules, isLogoShowed),\n b: getPixel(x, y + 1, size, modules, isLogoShowed),\n current: getPixel(x, y, size, modules, isLogoShowed),\n});\n\n/**\n * Converts QrCode instance to SVG code\n * @param qrCode QrCode instance\n * @param options Convertation options\n */\nexport const convertSegmentsToSvgString = (qrCode: QrCode, options: RequiredQrOptions): string => {\n if (typeof options.qrSize !== 'number') {\n throw new Error('Size should be a number');\n }\n\n if (typeof options.className !== 'string') {\n throw new Error('Classname should be a string');\n }\n\n const _2 = 2 * MULTI;\n const _12_7 = 12.7 * MULTI;\n const _12_8 = 12.8 * MULTI;\n const _14_7 = 14.7 * MULTI;\n const _14_8 = 14.8 * MULTI;\n const _15_9 = 15.9 * MULTI;\n const _28_6 = 28.6 * MULTI;\n const _30_5 = 30.5 * MULTI;\n const _84_7 = 84.7776815 * MULTI;\n const _87_3 = 87.3 * MULTI;\n const _71_4 = 71.4 * MULTI;\n const _42_9 = 42.9 * MULTI;\n const _87_2 = 87.2 * MULTI;\n const _85_2 = 85.2 * MULTI;\n const _85_3 = 85.3 * MULTI;\n const _69_5 = 69.5 * MULTI;\n const _98 = 98 * MULTI;\n const _100 = 100 * MULTI;\n\n const parts = [];\n let leftPadding = 0;\n let topPadding = 0;\n let xCoord = 0;\n let yCoord = 0;\n\n for (let y = 0; y < qrCode.size; y++) {\n leftPadding = 0;\n for (let x = 0; x < qrCode.size; x++) {\n xCoord = x + leftPadding;\n leftPadding += TILE_SIZE;\n yCoord = y + topPadding;\n\n const neighbors = getNeighbors(x, y, qrCode.size, qrCode.modules, options.isShowLogo);\n\n let path = '';\n let selector = '';\n\n if (neighbors.current) {\n selector =\n !selector && !neighbors.l && !neighbors.r && !neighbors.t && !neighbors.b ? 'empty' : '';\n selector =\n (!selector && neighbors.l && neighbors.r) || (neighbors.t && neighbors.b) ? 'rect' : '';\n if (!selector) {\n selector += neighbors.l ? 'l' : neighbors.r ? 'r' : '';\n selector += neighbors.t ? 't' : neighbors.b ? 'b' : '';\n if (!selector) {\n selector = 'empty';\n }\n }\n } else {\n selector =\n !selector &&\n neighbors.l &&\n neighbors.t &&\n getPixel(x - 1, y - 1, qrCode.size, qrCode.modules, options.isShowLogo)\n ? 'n_lt'\n : '';\n selector =\n !selector &&\n neighbors.l &&\n neighbors.b &&\n getPixel(x - 1, y + 1, qrCode.size, qrCode.modules, options.isShowLogo)\n ? 'n_lb'\n : '';\n selector =\n !selector &&\n neighbors.r &&\n neighbors.t &&\n getPixel(x + 1, y - 1, qrCode.size, qrCode.modules, options.isShowLogo)\n ? 'n_rt'\n : '';\n selector =\n !selector &&\n neighbors.r &&\n neighbors.b &&\n getPixel(x + 1, y + 1, qrCode.size, qrCode.modules, options.isShowLogo)\n ? 'n_rb'\n : '';\n }\n\n if (!selector) {\n continue;\n }\n path = `<use xlink:href=\"#${selector}-${options.suffix}\"/>`;\n parts.push(`<g transform=\"translate(${xCoord},${yCoord})\">${path}</g>`);\n }\n topPadding += TILE_SIZE;\n }\n\n let scale = '';\n let position = ((qrCode.size - QR_BORDER * 3) / 2) * TILE_SIZE + TILE_SIZE * QR_BORDER - 10;\n if (qrCode.size <= SMALL_QR_SIZE) {\n scale = 'scale(0.85)';\n position += 50;\n }\n\n const pointPosition = (qrCode.size - QR_BORDER) * options.incTileSize;\n parts.push(\n `<use fill-rule=\"evenodd\" transform=\"translate(0,0)\" xlink:href=\"#point-${options.suffix}\"/>`,\n );\n parts.push(\n `<use fill-rule=\"evenodd\" transform=\"translate(${pointPosition},0)\" xlink:href=\"#point-${options.suffix}\"/>`,\n );\n parts.push(\n `<use fill-rule=\"evenodd\" transform=\"translate(0,${pointPosition})\" xlink:href=\"#point-${options.suffix}\"/>`,\n );\n\n if (options.isShowLogo) {\n if (!options.logoData) {\n parts.push(`\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n fill=\"none\"\n fill-rule=\"evenodd\"\n transform=\"translate(${position},${position}) ${scale}\" xlink:href=\"#vk_logo-${options.suffix}\"\n />\n `);\n } else {\n parts.push(`\n <image\n preserveAspectRatio=\"xMidYMid slice\" clip-path=\"url(#logo-mask-${options.suffix})\"\n style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n transform=\"translate(${position},${position}) ${scale}\"\n xlink:href=\"${options.logoData}\"\n />\n `);\n }\n }\n\n const backgroundSize = 99 * qrCode.size;\n let qrBackground = '';\n let qrTransform = 'translate(0,0)';\n\n if (options.isShowBackground) {\n const qrScale = (options.qrSize - 20 * 2) / options.qrSize; // 0.756972112\n const padding = (backgroundSize / options.qrSize) * 21;\n const radius = Math.ceil(backgroundSize / (options.qrSize / 36)); // 7.11111111 = 256px/36px radius\n\n qrBackground = `\n <rect\n x=\"0\"\n width=\"${backgroundSize}\"\n height=\"${backgroundSize}\"\n rx=\"${radius}\"\n fill=\"${options.backgroundColor}\"\n />`;\n qrTransform = `translate(${padding}, ${padding}) scale(${qrScale})`;\n }\n\n // eslint-disable-next-line\n const oneSide = `M0,0 L66,0 C${_84_7},-3.44940413e-15 ${_100},15.2223185 ${_100},34 L${_100},66 C${_100},${_84_7} \\\n${_84_7},${_100} 66,${_100} L0,${_100} L0,0 Z`;\n const twoSides = `M0,0 L${_100},0 L${_100},66 C${_100},${_84_7} ${_84_7},${_100} 66,${_100} L0,${_100} L0,0 Z`;\n\n return `\n <svg\n version=\"1.1\"\n viewBox=\"0 0 ${backgroundSize} ${backgroundSize}\"\n width=\"${options.qrSize}px\"\n height=\"${options.qrSize}px\"\n ${options.className ? `class=\"${options.className}\"` : ''}\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <defs>\n <rect id=\"rect-${options.suffix}\" width=\"100\" height=\"100\" fill=\"${options.foregroundColor}\"/>\n <path\n id=\"empty-${options.suffix}\"\n d=\"M0,${_28_6}v${_42_9}C0,${_87_3},${_12_8},${_100},${_28_6},${_100}h${_42_9}c${_15_9},0,${_28_6}-${_12_8},\\\n${_28_6}-${_28_6}V${_28_6}C${_100},${_12_7},${_87_2},0,${_71_4},0H${_28_6} C${_12_8},0,0,${_12_8},0,${_28_6}z\"\n fill=\"${options.foregroundColor}\"\n />\n <path id=\"b-${options.suffix}\" d=\"${oneSide}\" transform=\"rotate(-90 50 50)\" fill=\"${options.foregroundColor}\"/>\n <path id=\"r-${options.suffix}\" d=\"${oneSide}\" transform=\"rotate(-180 50 50)\" fill=\"${options.foregroundColor}\"/>\n <path id=\"l-${options.suffix}\" d=\"${oneSide}\" fill=\"${options.foregroundColor}\"/>\n <path id=\"t-${options.suffix}\" d=\"${oneSide}\" transform=\"rotate(90 50 50)\" fill=\"${options.foregroundColor}\"/>\n <path id=\"l-${options.suffix}\" d=\"${twoSides}\" transform=\"rotate(-90 50 50)\" fill=\"${options.foregroundColor}\"/>\n <path id=\"lt-${options.suffix}\" d=\"${twoSides}\" fill=\"${options.foregroundColor}\"/>\n <path id=\"lb-${options.suffix}\" d=\"${twoSides}\" transform=\"rotate(-90 50 50)\" fill=\"${options.foregroundColor}\"/>\n <path id=\"rb-${options.suffix}\" d=\"${twoSides}\" transform=\"rotate(-180 50 50)\" fill=\"${options.foregroundColor}\"/>\n <path id=\"rt-${options.suffix}\" d=\"${twoSides}\" transform=\"rotate(90 50 50)\" fill=\"${options.foregroundColor}\"/>\n <path\n id=\"n_lt-${options.suffix}\"\n d=\"M${_30_5},${_2}V0H0v${_30_5}h${_2}C${_2},${_14_7},${_14_8},${_2},${_30_5},${_2}z\"\n fill=\"${options.foregroundColor}\"\n />\n <path\n id=\"n_lb-${options.suffix}\"\n d=\"M${_2},${_69_5}H0V${_100}h${_30_5}v-${_2}C${_14_7},${_98},${_2},${_85_2},${_2},${_69_5}z\"\n fill=\"${options.foregroundColor}\"\n />\n <path\n id=\"n_rt-${options.suffix}\"\n d=\"M${_98},${_30_5}h${_2}V0H${_69_5}v${_2}C${_85_3},${_2},${_98},${_14_8},${_98},${_30_5}z\"\n fill=\"${options.foregroundColor}\"\n />\n <path id=\"n_rb-${options.suffix}\"\n d=\"M${_69_5},${_98}v${_2}H${_100}V${_69_5}h-${_2}C${_98},${_85_3},${_85_2},${_98},${_69_5},${_98}z\"\n fill=\"${options.foregroundColor}\"\n />\n <path\n id=\"point-${options.suffix}\"\n fill=\"${options.foregroundColor}\"\n d=\"M600.001786,457.329333 L600.001786,242.658167 C600.001786,147.372368 587.039517,124.122784 \\\n581.464617,118.535383 C575.877216,112.960483 552.627632,99.9982143 457.329333,99.9982143 \\\nL242.670667,99.9982143 C147.372368,99.9982143 124.122784,112.960483 118.547883,118.535383 \\\nC112.972983,124.122784 99.9982143,147.372368 99.9982143,242.658167 L99.9982143,457.329333 \\\nC99.9982143,552.627632 112.972983,575.877216 118.547883,581.464617 C124.122784,587.027017 \\\n147.372368,600.001786 242.670667,600.001786 L457.329333,600.001786 C552.627632,600.001786 \\\n575.877216,587.027017 581.464617,581.464617 C587.039517,575.877216 600.001786,552.627632 \\\n600.001786,457.329333 Z M457.329333,0 C653.338333,0 700,46.6616668 700,242.658167 C700,438.667167 \\\n700,261.332833 700,457.329333 C700,653.338333 653.338333,700 457.329333,700 C261.332833,700 438.667167,700 \\\n242.670667,700 C46.6616668,700 0,653.338333 0,457.329333 C0,261.332833 0,352.118712 0,242.658167 \\\nC0,46.6616668 46.6616668,0 242.670667,0 C438.667167,0 261.332833,0 457.329333,0 Z M395.996667,200 \\\nC480.004166,200 500,220.008332 500,303.990835 C500,387.998334 500,312.001666 500,395.996667 \\\nC500,479.991668 480.004166,500 395.996667,500 C312.001666,500 387.998334,500 304.003333,500 C220.008332,500 \\\n200,479.991668 200,395.996667 C200,312.001666 200,350.906061 200,303.990835 C200,220.008332 220.008332,200 \\\n304.003333,200 C387.998334,200 312.001666,200 395.996667,200 Z\"\n />\n <g id=\"vk_logo-${options.suffix}\">\n <path\n fill=\"${options.logoColor}\"\n d=\"M83.3334 363.333C83.3334 231.34 83.3334 165.343 124.338 124.338C165.343 83.3333 231.34 \\\n 83.3333 363.333 83.3333H386.667C518.66 83.3333 584.657 83.3333 625.662 124.338C666.667 165.343 \\\n 666.667 231.34 666.667 363.333V386.667C666.667 518.66 666.667 584.657 625.662 625.662C584.657 \\\n 666.667 518.66 666.667 386.667 666.667H363.333C231.34 666.667 165.343 666.667 124.338 625.662C83.3334 \\\n 584.657 83.3334 518.66 83.3334 386.667V363.333Z\"\n />\n <path\n fill=\"#FFF\"\n d=\"M394.907 508.681C263.293 508.681 183.442 417.365 180.313 265.625H246.972C249.05 377.09 \\\n 299.763 424.323 338.638 434.036V265.625H402.519V361.82C440.016 357.664 479.264 313.909 \\\n 492.456 265.625H555.333C545.27 325 502.543 368.754 472.353 386.803C502.566 401.395 551.177 \\\n 439.593 569.926 508.681H500.815C486.222 462.498 450.476 426.728 402.542 421.872V508.681H394.907Z\"\n />\n </g>\n <clipPath id=\"logo-mask-${options.suffix}\">\n <rect x=\"0\" y=\"0\" width=\"750\" height=\"750\" />\n </clipPath>\n </defs>\n\n ${qrBackground}\n\n <g transform=\"${qrTransform}\">\n ${parts.join('\\n')}\n </g>\n </svg>`;\n};\n","/*\n * QR Code generator library (TypeScript)\n *\n * Copyright (c) Project Nayuki. (MIT License)\n * https://www.nayuki.io/page/qr-code-generator-library\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n * - The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * - The Software is provided \"as is\", without warranty of any kind, express or\n * implied, including but not limited to the warranties of merchantability,\n * fitness for a particular purpose and noninfringement. In no event shall the\n * authors or copyright holders be liable for any claim, damages or other\n * liability, whether in an action of contract, tort or otherwise, arising from,\n * out of or in connection with the Software or the use or other dealings in the\n * Software.\n */\n\ntype bit = number;\ntype byte = number;\ntype int = number;\n\n/*---- QR Code symbol class ----*/\n\n/*\n * A QR Code symbol, which is a type of two-dimension barcode.\n * Invented by Denso Wave and described in the ISO/IEC 18004 standard.\n * Instances of this class represent an immutable square grid of black and white cells.\n * The class provides static factory functions to create a QR Code from text or binary data.\n * The class covers the QR Code Model 2 specification, supporting all versions (sizes)\n * from 1 to 40, all 4 error correction levels, and 4 character encoding modes.\n *\n * Ways to create a QR Code object:\n * - High level: Take the payload data and call QrCode.encodeText() or QrCode.encodeBinary().\n * - Mid level: Custom-make the list of segments and call QrCode.encodeSegments().\n * - Low level: Custom-make the array of data codeword bytes (including\n * segment headers and final padding, excluding error correction codewords),\n * supply the appropriate version number, and call the QrCode() constructor.\n * (Note that all ways require supplying the desired error correction level.)\n */\nexport class QrCode {\n /*-- Static factory functions (high level) --*/\n\n // Returns a QR Code representing the given Unicode text string at the given error correction level.\n // As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer\n // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible\n // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the\n // ecl argument if it can be done without increasing the version.\n public static encodeText(text: string, ecl: QrCodeEcc): QrCode {\n const segs: Array<QrSegment> = QrSegment.makeSegments(text);\n return QrCode.encodeSegments(segs, ecl);\n }\n\n // Returns a QR Code representing the given binary data at the given error correction level.\n // This function always encodes using the binary segment mode, not any text mode. The maximum number of\n // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.\n // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.\n public static encodeBinary(data: Array<byte>, ecl: QrCodeEcc): QrCode {\n const seg: QrSegment = QrSegment.makeBytes(data);\n return QrCode.encodeSegments([seg], ecl);\n }\n\n /*-- Static factory functions (mid level) --*/\n\n // Returns a QR Code representing the given segments with the given encoding parameters.\n // The smallest possible QR Code version within the given range is automatically\n // chosen for the output. Iff boostEcl is true, then the ECC level of the result\n // may be higher than the ecl argument if it can be done without increasing the\n // version. The mask number is either between 0 to 7 (inclusive) to force that\n // mask, or -1 to automatically choose an appropriate mask (which may be slow).\n // This function allows the user to create a custom sequence of segments that switches\n // between modes (such as alphanumeric and byte) to encode text in less space.\n // This is a mid-level API; the high-level API is encodeText() and encodeBinary().\n public static encodeSegments(\n segs: Array<QrSegment>,\n ecl: QrCodeEcc,\n minVersion: int = 1,\n maxVersion: int = 40,\n mask: int = -1,\n boostEcl: boolean = true,\n ): QrCode {\n if (\n !(\n QrCode.MIN_VERSION <= minVersion &&\n minVersion <= maxVersion &&\n maxVersion <= QrCode.MAX_VERSION\n ) ||\n mask < -1 ||\n mask > 7\n )\n throw 'Invalid value';\n\n // Find the minimal version number to use\n let version: int;\n let dataUsedBits: int;\n for (version = minVersion; ; version++) {\n const dataCapacityBits: int = QrCode.getNumDataCodewords(version, ecl) * 8; // Number of data bits available\n const usedBits: number = QrSegment.getTotalBits(segs, version);\n if (usedBits <= dataCapacityBits) {\n dataUsedBits = usedBits;\n break; // This version number is found to be suitable\n }\n if (version >= maxVersion)\n // All versions in the range could not fit the given data\n throw 'Data too long';\n }\n\n // Increase the error correction level while the data still fits in the current version number\n for (const newEcl of [QrCodeEcc.MEDIUM, QrCodeEcc.QUARTILE, QrCodeEcc.HIGH]) {\n // From low to high\n if (boostEcl && dataUsedBits <= QrCode.getNumDataCodewords(version, newEcl) * 8) ecl = newEcl;\n }\n\n // Concatenate all segments to create the data bit string\n const bb = new BitBuffer();\n for (const seg of segs) {\n bb.appendBits(seg.mode.modeBits, 4);\n bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version));\n for (const b of seg.getData()) bb.array.push(b);\n }\n if (bb.array.length !== dataUsedBits) throw 'Assertion error';\n\n // Add terminator and pad up to a byte if applicable\n const dataCapacityBits: int = QrCode.getNumDataCodewords(version, ecl) * 8;\n if (bb.array.length > dataCapacityBits) throw 'Assertion error';\n bb.appendBits(0, Math.min(4, dataCapacityBits - bb.array.length));\n bb.appendBits(0, (8 - (bb.array.length % 8)) % 8);\n if (bb.array.length % 8 !== 0) throw 'Assertion error';\n\n // Pad with alternating bytes until data capacity is reached\n for (let padByte = 0xec; bb.array.length < dataCapacityBits; padByte ^= 0xec ^ 0x11)\n bb.appendBits(padByte, 8);\n\n // Pack bits into bytes in big endian\n const dataCodewords: Array<byte> = [];\n while (dataCodewords.length * 8 < bb.array.length) dataCodewords.push(0);\n bb.array.forEach((b: bit, i: int) => {\n dataCodewords[i >>> 3] |= b << (7 - (i & 7));\n });\n\n // Create the QR Code object\n return new QrCode(version, ecl, dataCodewords, mask);\n }\n\n /*-- Fields --*/\n\n // The width and height of this QR Code, measured in modules, between\n // 21 and 177 (inclusive). This is equal to version * 4 + 17.\n public readonly size: int;\n\n // The modules of this QR Code (false = white, true = black).\n // Immutable after constructor finishes. Accessed through getModule().\n public readonly modules: Array<Array<boolean>> = [];\n\n // Indicates function modules that are not subjected to masking. Discarded when constructor finishes.\n private readonly isFunction: Array<Array<boolean>> = [];\n\n /*-- Constructor (low level) and fields --*/\n\n // The version number of this QR Code, which is between 1 and 40 (inclusive).\n // This determines the size of this barcode.\n public readonly version: int;\n\n // The error correction level used in this QR Code.\n public readonly errorCorrectionLevel: QrCodeEcc;\n\n // The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive).\n // Even if a QR Code is created with automatic masking requested (mask = -1),\n // the resulting object still has a mask value between 0 and 7.\n public readonly mask: int;\n\n // Creates a new QR Code with the given version number,\n // error correction level, data codeword bytes, and mask number.\n // This is a low-level API that most users should not use directly.\n // A mid-level API is the encodeSegments() function.\n public constructor(\n version: int,\n errorCorrectionLevel: QrCodeEcc,\n dataCodewords: Array<byte>,\n mask: int,\n ) {\n // Check scalar arguments\n if (version < QrCode.MIN_VERSION || version > QrCode.MAX_VERSION)\n throw 'Version value out of range';\n if (mask < -1 || mask > 7) throw 'Mask value out of range';\n this.version = version;\n this.errorCorrectionLevel = errorCorrectionLevel;\n this.size = version * 4 + 17;\n\n // Initialize both grids to be size*size arrays of Boolean false\n const row: Array<boolean> = [];\n for (let i = 0; i < this.size; i++) row.push(false);\n for (let i = 0; i < this.size; i++) {\n this.modules.push(row.slice()); // Initially all white\n this.isFunction.push(row.slice());\n }\n\n // Compute ECC, draw modules\n this.drawFunctionPatterns();\n const allCodewords: Array<byte> = this.addEccAndInterleave(dataCodewords);\n this.drawCodewords(allCodewords);\n\n // Do masking\n if (mask === -1) {\n // Automatically choose best mask\n let minPenalty: int = 1000000000;\n for (let i = 0; i < 8; i++) {\n this.applyMask(i);\n this.drawFormatBits(i);\n const penalty: int = this.getPenaltyScore();\n if (penalty < minPenalty) {\n mask = i;\n minPenalty = penalty;\n }\n this.applyMask(i); // Undoes the mask due to XOR\n }\n }\n if (mask < 0 || mask > 7) throw 'Assertion error';\n this.mask = mask;\n this.applyMask(mask); // Apply the final choice of mask\n this.drawFormatBits(mask); // Overwrite old format bits\n\n this.isFunction = [];\n }\n\n /*-- Accessor methods --*/\n\n // Returns the color of the module (pixel) at the given coordinates, which is false\n // for white or true for black. The top left corner has the coordinates (x=0, y=0).\n // If the given coordinates are out of bounds, then false (white) is returned.\n public getModule(x: int, y: int): boolean {\n return 0 <= x && x < this.size && 0 <= y && y < this.size && this.modules[y][x];\n }\n\n /*-- Public instance methods --*/\n\n // Returns a string of SVG code for an image depicting this QR Code, with the given number\n // of border modules. The string always uses Unix newlines (\\n), regardless of the platform.\n public toSvgString(border: int): string {\n if (border < 0) throw 'Border must be non-negative';\n const parts: Array<string> = [];\n for (let y = 0; y < this.size; y++) {\n for (let x = 0; x < this.size; x++) {\n if (this.getModule(x, y)) parts.push(`M${x + border},${y + border}h1v1h-1z`);\n }\n }\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 ${this.size + border * 2} ${\n this.size + border * 2\n }\" stroke=\"none\">\n\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n\t<path d=\"${parts.join(' ')}\" fill=\"#000000\"/>\n</svg>\n`;\n }\n\n /*-- Private helper methods for constructor: Drawing function modules --*/\n\n // Reads this object's version field, and draws and marks all function modules.\n private drawFunctionPatterns(): void {\n // Draw horizontal and vertical timing patterns\n for (let i = 0; i < this.size; i++) {\n this.setFunctionModule(6, i, i % 2 === 0);\n this.setFunctionModule(i, 6, i % 2 === 0);\n }\n\n // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)\n this.drawFinderPattern(3, 3);\n this.drawFinderPattern(this.size - 4, 3);\n this.drawFinderPattern(3, this.size - 4);\n\n // Draw numerous alignment patterns\n const alignPatPos: Array<int> = this.getAlignmentPatternPositions();\n const numAlign: int = alignPatPos.length;\n for (let i = 0; i < numAlign; i++) {\n for (let j = 0; j < numAlign; j++) {\n // Don't draw on the three finder corners\n if (\n !(\n (i === 0 && j === 0) ||\n (i === 0 && j === numAlign - 1) ||\n (i === numAlign - 1 && j === 0)\n )\n )\n this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);\n }\n }\n\n // Draw configuration data\n this.drawFormatBits(0); // Dummy mask value; overwritten later in the constructor\n this.drawVersion();\n }\n\n // Draws two copies of the format bits (with its own error correction code)\n // based on the given mask and this object's error correction level field.\n private drawFormatBits(mask: int): void {\n // Calculate error correction code and pack bits\n const data: int = (this.errorCorrectionLevel.formatBits << 3) | mask; // errCorrLvl is uint2, mask is uint3\n let rem: int = data;\n for (let i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >>> 9) * 0x537);\n const bits = ((data << 10) | rem) ^ 0x5412; // uint15\n if (bits >>> 15 !== 0) throw 'Assertion error';\n\n // Draw first copy\n for (let i = 0; i <= 5; i++) this.setFunctionModule(8, i, getBit(bits, i));\n this.setFunctionModule(8, 7, getBit(bits, 6));\n this.setFunctionModule(8, 8, getBit(bits, 7));\n this.setFunctionModule(7, 8, getBit(bits, 8));\n for (let i = 9; i < 15; i++) this.setFunctionModule(14 - i, 8, getBit(bits, i));\n\n // Draw second copy\n for (let i = 0; i < 8; i++) this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));\n for (let i = 8; i < 15; i++) this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));\n this.setFunctionModule(8, this.size - 8, true); // Always black\n }\n\n // Draws two copies of the version bits (with its own error correction code),\n // based on this object's version field, iff 7 <= version <= 40.\n private drawVersion(): void {\n if (this.version < 7) return;\n\n // Calculate error correction code and pack bits\n let rem: int = this.version; // version is uint6, in the range [7, 40]\n for (let i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);\n const bits: int = (this.version << 12) | rem; // uint18\n if (bits >>> 18 !== 0) throw 'Assertion error';\n\n // Draw two copies\n for (let i = 0; i < 18; i++) {\n const color: boolean = getBit(bits, i);\n const a: int = this.size - 11 + (i % 3);\n const b: int = Math.floor(i / 3);\n this.setFunctionModule(a, b, color);\n this.setFunctionModule(b, a, color);\n }\n }\n\n // Draws a 9*9 finder pattern including the border separator,\n // with the center module at (x, y). Modules can be out of bounds.\n private drawFinderPattern(x: int, y: int): void {\n for (let dy = -4; dy <= 4; dy++) {\n for (let dx = -4; dx <= 4; dx++) {\n const dist: int = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm\n const xx: int = x + dx;\n const yy: int = y + dy;\n if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size)\n this.setFunctionModule(xx, yy, dist !== 2 && dist !== 4);\n }\n }\n }\n\n // Draws a 5*5 alignment pattern, with the center module\n // at (x, y). All modules must be in bounds.\n private drawAlignmentPattern(x: int, y: int): void {\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++)\n this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n }\n }\n\n // Sets the color of a module and marks it as a function module.\n // Only used by the constructor. Coordinates must be in bounds.\n private setFunctionModule(x: int, y: int, isBlack: boolean): void {\n this.modules[y][x] = isBlack;\n this.isFunction[y][x] = true;\n }\n\n /*-- Private helper methods for constructor: Codewords and masking --*/\n\n // Returns a new byte string representing the given data with the appropriate error correction\n // codewords appended to it, based on this object's version and error correction level.\n private addEccAndInterleave(data: Array<byte>): Array<byte> {\n const ver: int = this.version;\n const ecl: QrCodeEcc = this.errorCorrectionLevel;\n if (data.length !== QrCode.getNumDataCodewords(ver, ecl)) throw 'Invalid argument';\n\n // Calculate parameter numbers\n const numBlocks: int = QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];\n const blockEccLen: int = QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];\n const rawCodewords: int = Math.floor(QrCode.getNumRawDataModules(ver) / 8);\n const numShortBlocks: int = numBlocks - (rawCodewords % numBlocks);\n const shortBlockLen: int = Math.floor(rawCodewords / numBlocks);\n\n // Split data into blocks and append ECC to each block\n const blocks: Array<Array<byte>> = [];\n const rs = new ReedSolomonGenerator(blockEccLen);\n for (let i = 0, k = 0; i < numBlocks; i++) {\n const dat: Array<byte> = data.slice(\n k,\n k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1),\n );\n k += dat.length;\n const ecc: Array<byte> = rs.getRemainder(dat);\n if (i < numShortBlocks) dat.push(0);\n blocks.push(dat.concat(ecc));\n }\n\n // Interleave (not concatenate) the bytes from every block into a single sequence\n const result: Array<byte> = [];\n for (let i = 0; i < blocks[0].length; i++) {\n for (let j = 0; j < blocks.length; j++) {\n // Skip the padding byte in short blocks\n if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks) result.push(blocks[j][i]);\n }\n }\n if (result.length !== rawCodewords) throw 'Assertion error';\n return result;\n }\n\n // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire\n // data area of this QR Code. Function modules need to be marked off before this is called.\n private drawCodewords(data: Array<byte>): void {\n if (data.length !== Math.floor(QrCode.getNumRawDataModules(this.version) / 8))\n throw 'Invalid argument';\n let i: int = 0; // Bit index into the data\n // Do the funny zigzag scan\n for (let right = this.size - 1; right >= 1; right -= 2) {\n // Index of right column in each column pair\n if (right === 6) right = 5;\n for (let vert = 0; vert < this.size; vert++) {\n // Vertical counter\n for (let j = 0; j < 2; j++) {\n const x: int = right - j; // Actual x coordinate\n const upward: boolean = ((right + 1) & 2) === 0;\n const y: int = upward ? this.size - 1 - vert : vert; // Actual y coordinate\n if (!this.isFunction[y][x] && i < data.length * 8) {\n this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));\n i++;\n }\n // If this QR Code has any remainder bits (0 to 7), they were assigned as\n // 0/false/white by the constructor and are left unchanged by this method\n }\n }\n }\n if (i !== data.length * 8) throw 'Assertion error';\n }\n\n // XORs the codeword modules in this QR Code with the given mask pattern.\n // The function modules must be marked and the codeword bits must be drawn\n // before masking. Due to the arithmetic of XOR, calling applyMask() with\n // the same mask value a second time will undo the mask. A final well-formed\n // QR Code needs exactly one (not zero, two, etc.) mask applied.\n private applyMask(mask: int): void {\n if (mask < 0 || mask > 7) throw 'Mask value out of range';\n for (let y = 0; y < this.size; y++) {\n for (let x = 0; x < this.size; x++) {\n let invert: boolean;\n switch (mask) {\n case 0:\n invert = (x + y) % 2 === 0;\n break;\n case 1:\n invert = y % 2 === 0;\n break;\n case 2:\n invert = x % 3 === 0;\n break;\n case 3:\n invert = (x + y) % 3 === 0;\n break;\n case 4:\n invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;\n break;\n case 5:\n invert = ((x * y) % 2) + ((x * y) % 3) === 0;\n break;\n case 6:\n invert = (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;\n break;\n case 7:\n invert = (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;\n break;\n default:\n throw 'Assertion error';\n }\n if (!this.isFunction[y][x] && invert) this.modules[y][x] = !this.modules[y][x];\n }\n }\n }\n\n // Calculates and returns the penalty score based on state of this QR Code's current modules.\n // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.\n private getPenaltyScore(): int {\n let result: int = 0;\n\n // Adjacent modules in row having same color, and finder-like patterns\n for (let y = 0; y < this.size; y++) {\n const runHistory = [0, 0, 0, 0, 0, 0, 0];\n let color = false;\n let runX = 0;\n for (let x = 0; x < this.size; x++) {\n if (this.modules[y][x] === color) {\n runX++;\n if (runX === 5) result += QrCode.PENALTY_N1;\n else if (runX > 5) result++;\n } else {\n QrCode.addRunToHistory(runX, runHistory);\n if (!color && QrCode.hasFinderLikePattern(runHistory)) result += QrCode.PENALTY_N3;\n color = this.modules[y][x];\n runX = 1;\n }\n }\n QrCode.addRunToHistory(runX, runHistory);\n if (color) QrCode.addRunToHistory(0, runHistory); // Dummy run of white\n if (QrCode.hasFinderLikePattern(runHistory)) result += QrCode.PENALTY_N3;\n }\n // Adjacent modules in column having same color, and finder-like patterns\n for (let x = 0; x < this.size; x++) {\n const runHistory = [0, 0, 0, 0, 0, 0, 0];\n let color = false;\n let runY = 0;\n for (let y = 0; y < this.size; y++) {\n if (this.modules[y][x] === color) {\n runY++;\n if (runY === 5) result += QrCode.PENALTY_N1;\n else if (runY > 5) result++;\n } else {\n QrCode.addRunToHistory(runY, runHistory);\n if (!color && QrCode.hasFinderLikePattern(runHistory)) result += QrCode.PENALTY_N3;\n color = this.modules[y][x];\n runY = 1;\n }\n }\n QrCode.addRunToHistory(runY, runHistory);\n if (color) QrCode.addRunToHistory(0, runHistory); // Dummy run of white\n if (QrCode.hasFinderLikePattern(runHistory)) result += QrCode.PENALTY_N3;\n }\n\n // 2*2 blocks of modules having same color\n for (let y = 0; y < this.size - 1; y++) {\n for (let x = 0; x < this.size - 1; x++) {\n const color: boolean = this.modules[y][x];\n if (\n color === this.modules[y][x + 1] &&\n color === this.modules[y + 1][x] &&\n color === this.modules[y + 1][x + 1]\n )\n result += QrCode.PENALTY_N2;\n }\n }\n\n // Balance of black and white modules\n let black: int = 0;\n for (const row of this.modules) {\n for (const color of row) {\n if (color) black++;\n }\n }\n const total: int = this.size * this.size; // Note that size is odd, so black/total != 1/2\n // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)%\n const k: int = Math.ceil(Math.abs(black * 20 - total * 10) / total) - 1;\n result += k * QrCode.PENALTY_N4;\n return result;\n }\n\n /*-- Private helper functions --*/\n\n // Returns an ascending list of positions of alignment patterns for this version number.\n // Each position is in the range [0,177), and are used on both the x and y axes.\n // This could be implemented as lookup table of 40 variable-length lists of integers.\n private getAlignmentPatternPositions(): Array<int> {\n if (this.version === 1) return [];\n else {\n const numAlign: int = Math.floor(this.version / 7) + 2;\n const step: int =\n this.version === 32 ? 26 : Math.ceil((this.size - 13) / (numAlign * 2 - 2)) * 2;\n const result: Array<int> = [6];\n for (let pos = this.size - 7; result.length < numAlign; pos -= step) result.splice(1, 0, pos);\n return result;\n }\n }\n\n // Returns the number of data bits that can be stored in a QR Code of the given version number, after\n // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.\n // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.\n private static getNumRawDataModules(ver: int): int {\n if (ver < QrCode.MIN_VERSION || ver > QrCode.MAX_VERSION) throw 'Version number out of range';\n let result: int = (16 * ver + 128) * ver + 64;\n if (ver >= 2) {\n const numAlign: int = Math.floor(ver / 7) + 2;\n result -= (25 * numAlign - 10) * numAlign - 55;\n if (ver >= 7) result -= 36;\n }\n return result;\n }\n\n // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any\n // QR Code of the given version number and error correction level, with remainder bits discarded.\n // This stateless pure function could be implemented as a (40*4)-cell lookup table.\n private static getNumDataCodewords(ver: int, ecl: QrCodeEcc): int {\n return (\n Math.floor(QrCode.getNumRawDataModules(ver) / 8) -\n QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] *\n QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]\n );\n }\n\n // Inserts the given value to the front of the given array, which shifts over the\n // existing values and deletes the last value. A helper function for getPenaltyScore().\n private static addRunToHistory(run: int, history: Array<int>): void {\n history.pop();\n history.unshift(run);\n }\n\n // Tests whether the given run history has the pattern of ratio 1:1:3:1:1 in the middle, and\n // surrounded by at least 4 on either or both ends. A helper function for getPenaltyScore().\n // Must only be called immediately after a run of white modules has ended.\n private static hasFinderLikePattern(runHistory: Array<int>): boolean {\n const n: int = runHistory[1];\n return (\n n > 0 &&\n runHistory[2] === n &&\n runHistory[4] === n &&\n runHistory[5] === n &&\n runHistory[3] === n * 3 &&\n Math.max(runHistory[0], runHistory[6]) >= n * 4\n );\n }\n\n /*-- Constants and tables --*/\n\n // The minimum version number supported in the QR Code Model 2 standard.\n public static readonly MIN_VERSION: int = 1;\n // The maximum version number supported in the QR Code Model 2 standard.\n public static readonly MAX_VERSION: int = 40;\n\n // For use in getPenaltyScore(), when evaluating which mask is best.\n private static readonly PENALTY_N1: int = 3;\n private static readonly PENALTY_N2: int = 3;\n private static readonly PENALTY_N3: int = 40;\n private static readonly PENALTY_N4: int = 10;\n\n private static readonly ECC_CODEWORDS_PER_BLOCK: Array<Array<int>> = [\n /* eslint-disable */\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //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\n // prettier-ignore\n [\n -1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30,\n 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ], // Low\n // prettier-ignore\n [\n -1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28,\n 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ], // Medium\n // prettier-ignore\n [\n -1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30,\n 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ], // Quartile\n // prettier-ignore\n [\n -1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ], // High\n /* eslint-enable */\n ];\n\n private static readonly NUM_ERROR_CORRECTION_BLOCKS: Array<Array<int>> = [\n /* eslint-disable */\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //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\n // prettier-ignore\n [\n -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,\n 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25,\n ], // Low\n // prettier-ignore\n [\n -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,\n 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49,\n ], // Medium\n // prettier-ignore\n [\n -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,\n 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68,\n ], // Quartile\n // prettier-ignore\n [\n -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,\n 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81,\n ], // High\n /* eslint-enable */\n ];\n}\n\n// Returns true iff the i'th bit of x is set to 1.\nfunction getBit(x: int, i: int): boolean {\n return ((x >>> i) & 1) !== 0;\n}\n\n/*---- Data segment class ----*/\n\n/*\n * A segment of character/binary/control data in a QR Code symbol.\n * Instances of this class are immutable.\n * The mid-level way to create a segment is to take the payload data\n * and call a static factory function such as QrSegment.makeNumeric().\n * The low-level way to create a segment is to custom-make the bit buffer\n * and call the QrSegment() constructor with appropriate values.\n * This segment class imposes no length restrictions, but QR Codes have restrictions.\n * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.\n * Any segment longer than this is meaningless for the purpose of generating QR Codes.\n */\nexport class QrSegment {\n /*-- Static factory functions (mid level) --*/\n\n // Returns a segment representing the given binary data encoded in\n // byte mode. All input byte arrays are acceptable. Any text string\n // can be converted to UTF-8 bytes and encoded as a byte mode segment.\n public static makeBytes(data: Array<byte>): QrSegment {\n const bb = new BitBuffer();\n for (const b of data) bb.appendBits(b, 8);\n return new QrSegment(QrSegmentMode.BYTE, data.length, bb.array);\n }\n\n // Returns a segment representing the given string of decimal digits encoded in numeric mode.\n public static makeNumeric(digits: string): QrSegment {\n if (!QrSegment.NUMERIC_REGEX.test(digits)) throw 'String contains non-numeric characters';\n const bb = new BitBuffer();\n for (let i = 0; i < digits.length; ) {\n // Consume up to 3 digits per iteration\n const n: int = Math.min(digits.length - i, 3);\n bb.appendBits(parseInt(digits.substr(i, n), 10), n * 3 + 1);\n i += n;\n }\n return new QrSegment(QrSegmentMode.NUMERIC, digits.length, bb.array);\n }\n\n // Returns a segment representing the given text string encoded in alphanumeric mode.\n // The characters allowed are: 0 to 9, A to Z (uppercase only), space,\n // dollar, percent, asterisk, plus, hyphen, period, slash, colon.\n public static makeAlphanumeric(text: string): QrSegment {\n if (!QrSegment.ALPHANUMERIC_REGEX.test(text))\n throw 'String contains unencodable characters in alphanumeric mode';\n const bb = new BitBuffer();\n let i: int;\n for (i = 0; i + 2 <= text.length; i += 2) {\n // Process groups of 2\n let temp: int = QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;\n temp += QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));\n bb.appendBits(temp, 11);\n }\n if (i < text.length)\n // 1 character remaining\n bb.appendBits(QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6);\n return new QrSegment(QrSegmentMode.ALPHANUMERIC, text.length, bb.array);\n }\n\n // Returns a new mutable list of zero or more segments to represent the given Unicode text string.\n // The result may use various segment modes and switch modes to optimize the length of the bit stream.\n public static makeSegments(text: string): Array<QrSegment> {\n // Select the most efficient segment encoding automatically\n if (text === '') return [];\n else if (QrSegment.NUMERIC_REGEX.test(text)) return [QrSegment.makeNumeric(text)];\n else if (QrSegment.ALPHANUMERIC_REGEX.test(text)) return [QrSegment.makeAlphanumeric(text)];\n else return [QrSegment.makeBytes(QrSegment.toUtf8ByteArray(text))];\n }\n\n // Returns a segment representing an Extended Channel Interpretation\n // (ECI) designator with the given assignment value.\n public static makeEci(assignVal: int): QrSegment {\n const bb = new BitBuffer();\n if (assignVal < 0) throw 'ECI assignment value out of range';\n else if (assignVal < 1 << 7) bb.appendBits(assignVal, 8);\n else if (assignVal < 1 << 14) {\n bb.appendBits(2, 2);\n bb.appendBits(assignVal, 14);\n } else if (assignVal < 1000000) {\n bb.appendBits(6, 3);\n bb.appendBits(assignVal, 21);\n } else throw 'ECI assignment value out of range';\n return new QrSegment(QrSegmentMode.ECI, 0, bb.array);\n }\n\n /*-- Constructor (low level) and fields --*/\n\n // The mode indicator of this segment.\n public readonly mode: QrSegmentMode;\n\n // The length of this segment's unencoded data. Measured in characters for\n // numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.\n // Always zero or positive. Not the same as the data's bit length.\n public readonly numChars: int;\n\n // The data bits of this segment. Accessed through getData().\n private readonly bitData: Array<bit>;\n\n // Creates a new QR Code segment with the given attributes and data.\n // The character count (numChars) must agree with the mode and the bit buffer length,\n // but the constraint isn't checked. The given bit buffer is cloned and stored.\n public constructor(mode: QrSegmentMode, numChars: int, bitData: Array<bit>) {\n if (numChars < 0) throw 'Invalid argument';\n this.mode = mode;\n this.numChars = numChars;\n this.bitData = bitData.slice(); // Make defensive copy\n }\n\n /*-- Methods --*/\n\n // Returns a new copy of the data bits of this segment.\n public getData(): Array<bit> {\n return this.bitData.slice(); // Make defensive copy\n }\n\n // (Package-private) Calculates and returns the number of bits needed to encode the given segments at\n // the given version. The result is infinity if a segment has too many characters to fit its length field.\n public static getTotalBits(segs: Array<QrSegment>, version: int): number {\n let result: number = 0;\n for (const seg of segs) {\n const ccbits: int = seg.mode.numCharCountBits(version);\n if (seg.numChars >= 1 << ccbits) return Infinity; // The segment's length doesn't fit the field's bit width\n result += 4 + ccbits + seg.bitData.length;\n }\n return result;\n }\n\n // Returns a new array of bytes representing the given string encoded in UTF-8.\n private static toUtf8ByteArray(str: string): Array<byte> {\n str = encodeURI(str);\n const result: Array<byte> = [];\n for (let i = 0; i < str.length; i++) {\n if (str.charAt(i) !== '%') result.push(str.charCodeAt(i));\n else {\n result.push(parseInt(str.substr(i + 1, 2), 16));\n i += 2;\n }\n }\n return result;\n }\n\n /*-- Constants --*/\n\n // Describes precisely all strings that are encodable in numeric mode. To test\n // whether a string s is encodable: let ok: boolean = NUMERIC_REGEX.test(s);\n // A string is encodable iff each character is in the range 0 to 9.\n public static readonly NUMERIC_REGEX: RegExp = /^[0-9]*$/;\n\n // Describes precisely all strings that are encodable in alphanumeric mode. To test\n // whether a string s is encodable: let ok: boolean = ALPHANUMERIC_REGEX.test(s);\n // A string is encodable iff each character is in the following set: 0 to 9, A to Z\n // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.\n public static readonly ALPHANUMERIC_REGEX: RegExp = /^[A-Z0-9 $%*+./:-]*$/;\n\n // The set of all legal characters in alphanumeric mode,\n // where each character value maps to the index in the string.\n private static readonly ALPHANUMERIC_CHARSET: string =\n '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';\n}\n\n/*---- Private helper classes ----*/\n\n/*\n * Computes the Reed-Solomon error correction codewords for a sequence of data codewords\n * at a given degree. Objects are immutable, and the state only depends on the degree.\n * This class exists because each data block in a QR Code shares the same the divisor polynomial.\n */\nclass ReedSolomonGenerator {\n // Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which\n // is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}.\n private readonly coefficients: Array<byte> = [];\n\n // Creates a Reed-Solomon ECC generator for the given degree. This could be implemented\n // as a lookup table over all possible parameter values, instead of as an algorithm.\n public constructor(degree: int) {\n if (degree < 1 || degree > 255) throw 'Degree out of range';\n const coefs = this.coefficients;\n\n // Start with the monomial x^0\n for (let i = 0; i < degree - 1; i++) coefs.push(0);\n coefs.push(1);\n\n // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}),\n // drop the highest term, and store the rest of the coefficients in order of descending powers.\n // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D).\n let root = 1;\n for (let i = 0; i < degree; i++) {\n // Multiply the current product by (x - r^i)\n for (let j = 0; j < coefs.length; j++) {\n coefs[j] = ReedSolomonGenerator.multiply(coefs[j], root);\n if (j + 1 < coefs.length) coefs[j] ^= coefs[j + 1];\n }\n root = ReedSolomonGenerator.multiply(root, 0x02);\n }\n }\n\n // Computes and returns the Reed-Solomon error correction codewords for the given\n // sequence of data codewords. The returned object is always a new byte array.\n // This method does not alter this object's state (because it is immutable).\n public getRemainder(data: Array<byte>): Array<byte> {\n // Compute the remainder by performing polynomial division\n const result: Array<byte> = this.coefficients.map((_) => 0);\n for (const b of data) {\n const factor: byte = b ^ (result.shift() as byte);\n result.push(0);\n this.coefficients.forEach((coef, i) => {\n result[i] ^= ReedSolomonGenerator.multiply(coef, factor);\n });\n }\n return result;\n }\n\n // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result\n // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.\n private static multiply(x: byte, y: byte): byte {\n if (x >>> 8 !== 0 || y >>> 8 !== 0) throw 'Byte out of range';\n // Russian peasant multiplication\n let z: int = 0;\n for (let i = 7; i >= 0; i--) {\n z = (z << 1) ^ ((z >>> 7) * 0x11d);\n z ^= ((y >>> i) & 1) * x;\n }\n if (z >>> 8 !== 0) throw 'Assertion error';\n return z as byte;\n }\n}\n\n/*\n * An appendable sequence of bits (0s and 1s). Mainly used by QrSegment.\n * The implicit constructor creates an empty bit buffer (length 0).\n */\nclass BitBuffer {\n public array: Array<bit> = [];\n\n // Appends the given number of low-order bits of the given value\n // to this buffer. Requires 0 <= len <= 31 and 0 <= val < 2^len.\n public appendBits(val: int, len: int): void {\n if (len < 0 || len > 31 || val >>> len !== 0) throw 'Value out of range';\n for (\n let i = len - 1;\n i >= 0;\n i-- // Append bit by bit\n )\n this.array.push((val >>> i) & 1);\n }\n}\n\n/*---- Public helper enumeration ----*/\n\n/*\n * The error correction level in a QR Code symbol. Immutable.\n */\nexport class QrCodeEcc {\n /*-- Constants --*/\n\n public static readonly LOW = new QrCodeEcc(0, 1); // The QR Code can tolerate about 7% erroneous codewords\n public static readonly MEDIUM = new QrCodeEcc(1, 0); // The QR Code can tolerate about 15% erroneous codewords\n public static readonly QUARTILE = new QrCodeEcc(2, 3); // The QR Code can tolerate about 25% erroneous codewords\n public static readonly HIGH = new QrCodeEcc(3, 2); // The QR Code can tolerate about 30% erroneous codewords\n\n /*-- Constructor and fields --*/\n\n // In the range 0 to 3 (unsigned 2-bit integer).\n public readonly ordinal: int;\n // (Package-private) In the range 0 to 3 (unsigned 2-bit integer).\n public readonly formatBits: int;\n\n private constructor(ordinal: int, formatBits: int) {\n this.ordinal = ordinal;\n this.formatBits = formatBits;\n }\n}\n\n/*---- Public helper enumeration ----*/\n\n/*\n * Describes how a segment's data bits are interpreted. Immutable.\n */\nexport class QrSegmentMode {\n /*-- Constants --*/\n\n public static readonly NUMERIC = new QrSegmentMode(0x1, [10, 12, 14]);\n public static readonly ALPHANUMERIC = new QrSegmentMode(0x2, [9, 11, 13]);\n public static readonly BYTE = new QrSegmentMode(0x4, [8, 16, 16]);\n public static readonly KANJI = new QrSegmentMode(0x8, [8, 10, 12]);\n public static readonly ECI = new QrSegmentMode(0x7, [0, 0, 0]);\n\n /*-- Constructor and fields --*/\n\n // The mode indicator bits, which is a uint4 value (range 0 to 15).\n public readonly modeBits: int;\n // Number of character count bits for three different version ranges.\n private readonly numBitsCharCount: [int, int, int];\n\n private constructor(modeBits: int, numBitsCharCount: [int, int, int]) {\n this.modeBits = modeBits;\n this.numBitsCharCount = numBitsCharCount;\n }\n\n /*-- Method --*/\n\n // (Package-private) Returns the bit width of the character count field for a segment in\n // this mode in a QR Code at the given version number. The result is in the range [0, 16].\n public numCharCountBits(ver: int): int {\n return this.numBitsCharCount[Math.floor((ver + 7) / 17)];\n }\n}\n","import { convertSegmentsToSvgString, INC_TILE_SIZE } from './svg.ts';\nimport { QrSegment, QrCode, QrCodeEcc } from './qr.ts';\nimport type { QrOptions, RequiredQrOptions } from './types.ts';\n\n/** Default width and height of QR code */\nconst DEFAULT_SIZE = 128;\n\n/** Default background color of QR code*/\nconst BACKGROUND_COLOR_DEFAULT = '#ffffff';\n\n/** Default foreground color */\nconst FOREGROUND_COLOR_DEFAULT = '#000000';\n\n/** Default logo color */\nconst LOGO_COLOR_DEFAULT = '#07f';\n\n/**\n * Generates SVG QR code by a text\n * @param text String to encode\n * @param options QR code options\n */\nexport function createQR(text: string, options?: QrOptions): string;\n\n/**\n * Legacy interface\n * @deprecated\n * @param text String to encode\n * @param qrSize Size of QR code\n * @param className SVG element class name\n * @param options Options of the QR code\n */\nexport function createQR(\n text: string,\n qrSize: number,\n className: string,\n options?: QrOptions,\n): string;\n\n/**\n * Implementation\n */\nexport function createQR(\n text: string,\n qrSizeOrOptions?: number | QrOptions,\n classNameLegacy?: string,\n legacyOptions?: QrOptions,\n): string {\n if (typeof text !== 'string') {\n throw new TypeError('Enter text for encoding');\n }\n\n // Legacy interface resolve\n const options: QrOptions = {\n ...(typeof qrSizeOrOptions === 'object' && qrSizeOrOptions !== null ? qrSizeOrOptions : {}),\n ...(typeof legacyOptions === 'object' && legacyOptions !== null ? legacyOptions : {}),\n qrSize:\n typeof qrSizeOrOptions === 'object' &&\n qrSizeOrOptions !== null &&\n typeof qrSizeOrOptions.qrSize === 'number'\n ? qrSizeOrOptions.qrSize\n : (qrSizeOrOptions as number),\n className:\n typeof qrSizeOrOptions === 'object' &&\n qrSizeOrOptions !== null &&\n typeof qrSizeOrOptions.className === 'string'\n ? qrSizeOrOptions.className\n : classNameLegacy,\n };\n\n // ECC levels mapping\n const eccLevels = [QrCodeEcc.LOW, QrCodeEcc.MEDIUM, QrCodeEcc.QUARTILE, QrCodeEcc.HIGH];\n\n // Fallback undefined options\n const fallbackOptions: RequiredQrOptions = {\n qrSize: typeof options.qrSize === 'number' ? options.qrSize : DEFAULT_SIZE,\n className: typeof options.className === 'string' ? options.className : classNameLegacy || '',\n isShowLogo: !!options.isShowLogo || false,\n isShowBackground: !!options.isShowBackground || false,\n foregroundColor:\n typeof options.foregroundColor === 'string'\n ? options.foregroundColor\n : FOREGROUND_COLOR_DEFAULT,\n backgroundColor:\n typeof options.backgroundColor === 'string'\n ? options.backgroundColor\n : BACKGROUND_COLOR_DEFAULT,\n logoColor: typeof options.logoColor === 'string' ? options.logoColor : LOGO_COLOR_DEFAULT,\n suffix: options.suffix ? options.suffix.toString() : '0',\n logoData: typeof options.logoData === 'string' ? options.logoData : null,\n ecc: typeof options.ecc === 'number' && eccLevels[options.ecc] ? options.ecc : 3,\n incTileSize: typeof options.incTileSize === 'number' ? options.incTileSize : INC_TILE_SIZE,\n };\n\n // Code generation\n const segments: QrSegment[] = QrSegment.makeSegments(text);\n const qrCode: QrCode = QrCode.encodeSegments(\n segments,\n eccLevels[fallbackOptions.ecc],\n 1,\n 40,\n -1,\n true,\n );\n const svgCode = convertSegmentsToSvgString(qrCode, fallbackOptions);\n\n return svgCode;\n}\n"],"names":["MULTI","QR_BORDER","TILE_SIZE","SMALL_QR_SIZE","getPixel","x","y","size","modules","isLogoShowed","imageTiles","paddingTiles","getNeighbors","convertSegmentsToSvgString","qrCode","options","Error","_2","_12_7","_12_8","_14_7","_14_8","_15_9","_28_6","_30_5","_84_7","_87_3","_71_4","_42_9","_87_2","_85_2","_85_3","_69_5","_98","_100","parts","leftPadding","topPadding","xCoord","yCoord","neighbors","path","selector","scale","position","pointPosition","backgroundSize","qrBackground","qrTransform","qrScale","padding","radius","Math","oneSide","twoSides","QrCode","text","ecl","segs","QrSegment","data","seg","minVersion","maxVersion","mask","boostEcl","version","dataUsedBits","dataCapacityBits","usedBits","newEcl","QrCodeEcc","bb","BitBuffer","b","padByte","dataCodewords","i","border","alignPatPos","numAlign","j","rem","bits","getBit","color","a","dy","dx","dist","xx","yy","isBlack","ver","numBlocks","blockEccLen","rawCodewords","numShortBlocks","shortBlockLen","blocks","rs","ReedSolomonGenerator","k","dat","ecc","result","right","vert","upward","invert","runHistory","runX","runY","black","row","total","step","pos","run","history","n","errorCorrectionLevel","allCodewords","minPenalty","penalty","QrSegmentMode","digits","parseInt","temp","assignVal","ccbits","Infinity","str","encodeURI","mode","numChars","bitData","_","factor","coef","z","degree","coefs","root","val","len","ordinal","formatBits","modeBits","numBitsCharCount","DEFAULT_SIZE","BACKGROUND_COLOR_DEFAULT","FOREGROUND_COLOR_DEFAULT","LOGO_COLOR_DEFAULT","createQR","qrSizeOrOptions","classNameLegacy","legacyOptions","TypeError","eccLevels","fallbackOptions","INC_TILE_SIZE","segments","svgCode"],"mappings":";AAGA,MAAMA,QAAQ;AACd,MAAMC,YAAY;AAClB,MAAMC,YAAY,KAAKF;AAEvB,MAAMG,gBAAgB;AAOtB,MAAMC,WAAW,CACfC,GACAC,GACAC,MACAC,SACAC;IAEA,IAAIJ,IAAIJ,aAAaK,IAAIL,WACvB,OAAO;IAGT,IAAII,KAAKE,OAAON,aAAaK,IAAIL,WAC/B,OAAO;IAGT,IAAII,IAAIJ,aAAaK,KAAKC,OAAON,WAC/B,OAAO;IAGT,IAAIQ,cAAc;QAChB,IAAIC,aAAaT,YAAY;QAC7B,IAAIM,QAAQJ,eACVO;QAGF,IAAIC,eAAgBJ,AAAAA,CAAAA,OAAON,AAAY,IAAZA,YAAgBS,UAAS,IAAK,IAAI;QAC7D,IAAIH,QAAQJ,eACVQ;QAGF,IACEN,IAAIJ,YAAYU,gBAChBN,IAAIE,OAAON,YAAYU,eAAe,KACtCL,IAAIL,YAAYU,gBAChBL,IAAIC,OAAON,YAAYU,eAAe,GAEtC,OAAO;QAGT,OAAO,KAAKN,KAAKA,IAAIE,QAAQ,KAAKD,KAAKA,IAAIC,QAAQC,OAAO,CAACF,EAAE,CAACD,EAAE;IAClE;IAEA,OAAOG,OAAO,CAACF,EAAE,EAAE,CAACD,EAAE;AACxB;AAEA,MAAMO,eAAe,CACnBP,GACAC,GACAC,MACAC,SACAC,eAAe,IAAI,GACf;QACJ,GAAGL,SAAS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ACvBwI;QACN,WAAW,AAA6B,YAA7B,OAAOxI,QAAQ,SAAS,GAAgBA,QAAQ,SAAS,GAAG0I;QACvE,QAAQ1I,QAAQ,MAAM,GAAGA,QAAQ,MAAM,CAAC,QAAQ,KAAK;QACrD,UAAU,AAA4B,YAA5B,OAAOA,QAAQ,QAAQ,GAAgBA,QAAQ,QAAQ,GAAG;QACpE,KAAK,AAAuB,YAAvB,OAAOA,QAAQ,GAAG,IAAiBgJ,SAAS,CAAChJ,QAAQ,GAAG,CAAC,GAAGA,QAAQ,GAAG,GAAG;QAC/E,aAAa,AAA+B,YAA/B,OAAOA,QAAQ,WAAW,GAAgBA,QAAQ,WAAW,GAAGkJ;IAC/E;IAGA,MAAMC,WAAwBvG,UAAU,YAAY,CAACH;IACrD,MAAM1C,SAAiByC,OAAO,cAAc,CAC1C2G,UACAH,SAAS,CAACC,gBAAgB,GAAG,CAAC,EAC9B,GACA,IACA,IACA;IAEF,MAAMG,UAAUtJ,2BAA2BC,QAAQkJ;IAEnD,OAAOG;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/figures.ts","../src/svg-path.ts","../src/svg.ts","../src/qr.ts","../src/index.ts"],"sourcesContent":["import { FINDER_PATTERN_SIZE } from './constants.ts';\n\n/** A connected group of modules stored in its smallest bounding box. */\nexport interface Figure {\n x: number;\n y: number;\n pixels: boolean[][];\n}\n\nexport function isFinderPattern(figure: Figure, size: number): boolean {\n const { x, y, pixels } = figure;\n const width = pixels[0]?.length ?? 0;\n const height = pixels.length;\n const right = x + width - 1;\n const bottom = y + height - 1;\n\n const finderRegions: Array<[number, number, number, number]> = [\n [0, 0, FINDER_PATTERN_SIZE - 1, FINDER_PATTERN_SIZE - 1],\n [size - FINDER_PATTERN_SIZE, 0, size - 1, FINDER_PATTERN_SIZE - 1],\n [0, size - FINDER_PATTERN_SIZE, FINDER_PATTERN_SIZE - 1, size - 1],\n ];\n\n for (const [rx1, ry1, rx2, ry2] of finderRegions) {\n if (x >= rx1 && y >= ry1 && right <= rx2 && bottom <= ry2) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function extractFigures(image: boolean[][]): Figure[] {\n const height = image.length;\n const width = image[0]?.length ?? 0;\n\n const visited: boolean[][] = Array.from({ length: height }, () => Array(width).fill(false));\n\n const figures: Figure[] = [];\n\n const directions = [\n [0, -1], // up\n [1, 0], // right\n [0, 1], // down\n [-1, 0], // left\n ];\n\n function isInside(x: number, y: number): boolean {\n return y >= 0 && y < height && x >= 0 && x < width;\n }\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n if (visited[y][x]) continue;\n if (!image[y][x]) continue;\n\n const cells: Array<[number, number]> = [[x, y]];\n\n visited[y][x] = true;\n\n let minX = x;\n let maxX = x;\n let minY = y;\n let maxY = y;\n\n for (let head = 0; head < cells.length; head++) {\n const [cx, cy] = cells[head];\n\n minX = Math.min(minX, cx);\n maxX = Math.max(maxX, cx);\n minY = Math.min(minY, cy);\n maxY = Math.max(maxY, cy);\n\n for (const [dx, dy] of directions) {\n const nx = cx + dx;\n const ny = cy + dy;\n\n if (!isInside(nx, ny)) continue;\n if (visited[ny][nx]) continue;\n if (!image[ny][nx]) continue;\n\n visited[ny][nx] = true;\n cells.push([nx, ny]);\n }\n }\n\n const figureWidth = maxX - minX + 1;\n const figureHeight = maxY - minY + 1;\n\n const pixels: boolean[][] = Array.from({ length: figureHeight }, () =>\n Array(figureWidth).fill(false),\n );\n\n for (const [cellX, cellY] of cells) {\n pixels[cellY - minY][cellX - minX] = true;\n }\n\n figures.push({\n x: minX,\n y: minY,\n pixels,\n });\n }\n }\n\n return figures;\n}\n","import { MODULE_CORNER_RADIUS, TILE_SIZE } from './constants.ts';\nimport type { Figure } from './figures.ts';\n\ninterface SvgPathOptions {\n pixelSize?: number;\n radius?: number;\n}\n\ninterface Point {\n x: number;\n y: number;\n}\n\ninterface Edge {\n from: Point;\n to: Point;\n}\n\ntype CornerRadius = (prev: Point, current: Point, next: Point) => number;\n\nexport function figureToSvgPath(figure: Figure, options: SvgPathOptions = {}): string {\n const pixelSize = options.pixelSize ?? TILE_SIZE;\n const radius = options.radius ?? MODULE_CORNER_RADIUS;\n const contours = buildContours(getBoundaryEdges(figure, pixelSize));\n const cornerRadius = createCornerRadiusResolver(figure, pixelSize, radius);\n\n return contours.map((contour) => contourToRoundedPath(contour, cornerRadius)).join(' ');\n}\n\nfunction hasPixel(pixels: boolean[][], x: number, y: number): boolean {\n return pixels[y]?.[x] ?? false;\n}\n\nfunction getBoundaryEdges(figure: Figure, pixelSize: number): Edge[] {\n const pixels = figure.pixels;\n const height = pixels.length;\n const width = pixels[0]?.length ?? 0;\n\n const edges: Edge[] = [];\n\n function px(x: number): number {\n return (figure.x + x) * pixelSize;\n }\n\n function py(y: number): number {\n return (figure.y + y) * pixelSize;\n }\n\n // Trace exposed edges with the filled module on their right.\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n if (!pixels[y][x]) continue;\n\n const left = px(x);\n const right = px(x + 1);\n const top = py(y);\n const bottom = py(y + 1);\n\n if (!hasPixel(pixels, x, y - 1)) {\n edges.push({\n from: { x: left, y: top },\n to: { x: right, y: top },\n });\n }\n\n if (!hasPixel(pixels, x + 1, y)) {\n edges.push({\n from: { x: right, y: top },\n to: { x: right, y: bottom },\n });\n }\n\n if (!hasPixel(pixels, x, y + 1)) {\n edges.push({\n from: { x: right, y: bottom },\n to: { x: left, y: bottom },\n });\n }\n\n if (!hasPixel(pixels, x - 1, y)) {\n edges.push({\n from: { x: left, y: bottom },\n to: { x: left, y: top },\n });\n }\n }\n }\n\n return edges;\n}\n\nfunction hasFilledCorner(\n pixels: boolean[][],\n x: number,\n y: number,\n dx: number,\n dy: number,\n): boolean {\n return (\n hasPixel(pixels, x + dx, y) && hasPixel(pixels, x, y + dy) && hasPixel(pixels, x + dx, y + dy)\n );\n}\n\nfunction createCornerRadiusResolver(\n figure: Figure,\n pixelSize: number,\n radius: number,\n): CornerRadius {\n return (prev: Point, current: Point, next: Point): number => {\n if (getTurn(prev, current, next) < 0) {\n const x = Math.round(Math.min(prev.x, current.x, next.x) / pixelSize) - figure.x;\n const y = Math.round(Math.min(prev.y, current.y, next.y) / pixelSize) - figure.y;\n\n // Each old selector assignment reset the previous match when it failed.\n // Consequently only n_rb could survive the final assignment.\n const topLeft = hasFilledCorner(figure.pixels, x, y, -1, -1);\n const bottomLeft = hasFilledCorner(figure.pixels, x, y, -1, 1);\n const topRight = hasFilledCorner(figure.pixels, x, y, 1, -1);\n const bottomRight = hasFilledCorner(figure.pixels, x, y, 1, 1);\n const roundsBottomRight = bottomRight && (!topRight || (bottomLeft && !topLeft));\n\n return roundsBottomRight &&\n current.x === (figure.x + (x + 1)) * pixelSize &&\n current.y === (figure.y + (y + 1)) * pixelSize\n ? radius\n : 0;\n }\n\n return radius;\n };\n}\n\nfunction buildContours(edges: Edge[]): Point[][] {\n const edgeMap = new Map<string, Point[]>();\n\n for (const edge of edges) {\n const key = pointKey(edge.from);\n const list = edgeMap.get(key);\n if (list) {\n list.push(edge.to);\n } else {\n edgeMap.set(key, [edge.to]);\n }\n }\n\n const contours: Point[][] = [];\n\n while (true) {\n const startKey = edgeMap.keys().next().value;\n if (startKey === undefined) break;\n\n const [x, y] = startKey.split(',').map(Number);\n const start = { x, y };\n\n const contour: Point[] = [start];\n let current = start;\n\n while (true) {\n const candidates = edgeMap.get(pointKey(current));\n\n if (!candidates || candidates.length === 0) {\n throw new Error('Broken contour: edge chain is not closed');\n }\n\n // At a diagonal touch, keep the filled pixel on the right of the edge.\n // Otherwise two convex corners become concave and a false hole is traced.\n let nextIndex = 0;\n if (candidates.length > 1 && contour.length > 1) {\n const prev = contour[contour.length - 2];\n const rightTurn = candidates.findIndex(\n (candidate) => getTurn(prev, current, candidate) > 0,\n );\n if (rightTurn !== -1) nextIndex = rightTurn;\n }\n const [next] = candidates.splice(nextIndex, 1);\n if (candidates.length === 0) edgeMap.delete(pointKey(current));\n\n if (samePoint(next, start)) {\n break;\n }\n\n contour.push(next);\n current = next;\n }\n\n contours.push(contour);\n }\n\n return contours;\n}\n\nfunction contourToRoundedPath(contour: Point[], cornerRadius: CornerRadius): string {\n const n = contour.length;\n\n if (n === 0) return '';\n\n const commands: string[] = [];\n\n for (let i = 0; i < n; i++) {\n const prev = contour[(i - 1 + n) % n];\n const current = contour[i];\n const next = contour[(i + 1) % n];\n\n const incomingLength = distance(current, prev);\n const outgoingLength = distance(current, next);\n\n const r = Math.min(cornerRadius(prev, current, next), incomingLength / 2, outgoingLength / 2);\n\n const beforeCorner = moveTowards(current, prev, r);\n const afterCorner = moveTowards(current, next, r);\n\n commands.push(`${i === 0 ? 'M' : 'L'} ${beforeCorner.x} ${beforeCorner.y}`);\n\n if (r > 0) {\n commands.push(`Q ${current.x} ${current.y} ${afterCorner.x} ${afterCorner.y}`);\n }\n }\n\n commands.push('Z');\n\n return commands.join(' ');\n}\n\nfunction moveTowards(from: Point, to: Point, distanceValue: number): Point {\n const length = distance(from, to);\n\n if (length === 0) {\n return { ...from };\n }\n\n const ratio = distanceValue / length;\n\n return {\n x: from.x + (to.x - from.x) * ratio,\n y: from.y + (to.y - from.y) * ratio,\n };\n}\n\nfunction distance(a: Point, b: Point): number {\n return Math.hypot(a.x - b.x, a.y - b.y);\n}\n\nfunction pointKey(point: Point): string {\n return `${point.x},${point.y}`;\n}\n\nfunction samePoint(a: Point, b: Point): boolean {\n return a.x === b.x && a.y === b.y;\n}\n\n/** Positive for a right turn in SVG's downward-pointing Y axis. */\nfunction getTurn(prev: Point, current: Point, next: Point): number {\n return (current.x - prev.x) * (next.y - current.y) - (current.y - prev.y) * (next.x - current.x);\n}\n","import type { QrCode } from './qr.ts';\nimport type { RequiredQrOptions } from './types.ts';\nimport { extractFigures, isFinderPattern } from './figures.ts';\nimport { figureToSvgPath } from './svg-path.ts';\nimport {\n FINDER_PATTERN_SIZE,\n TILE_SIZE,\n SMALL_QR_SIZE,\n FINDER_CORNER_RADIUS,\n} from './constants.ts';\n\nexport const INC_TILE_SIZE = TILE_SIZE;\n\ninterface BackgroundLayout {\n size: number;\n padding: number;\n radius: number;\n hideQr: boolean;\n}\n\n/** Converts a QR module matrix to SVG. */\nexport function convertSegmentsToSvgString(qrCode: QrCode, options: RequiredQrOptions): string {\n if (typeof options.qrSize !== 'number') {\n throw new Error('Size should be a number');\n }\n\n if (typeof options.className !== 'string') {\n throw new Error('Classname should be a string');\n }\n\n const background = getBackgroundLayout(qrCode.size, options);\n const parts = renderFinderPatterns(qrCode.size, options);\n if (options.isShowLogo) parts.push(renderLogo(qrCode.size, options));\n\n return `\n <svg\n version=\"1.1\"\n viewBox=\"${-background.padding} ${-background.padding} ${background.size} ${background.size}\"\n width=\"${options.qrSize}px\"\n height=\"${options.qrSize}px\"\n style=\"display: block\"\n ${options.className ? `class=\"${options.className}\"` : ''}\n xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n ${renderDefinitions(options)}\n\n ${renderBackground(background, options)}\n\n <g${background.hideQr ? ' display=\"none\"' : ''}>\n ${renderModules(qrCode, options)}\n ${parts.join('\\n')}\n </g>\n\n </svg>`;\n}\n\nfunction getVisibleModules(qrCode: QrCode, isShowLogo: boolean): boolean[][] {\n if (!isShowLogo) return qrCode.modules;\n\n // Clear the logo area before tracing contours so transparent logos retain\n // their quiet zone and neighboring modules do not connect through it.\n const logoAreaSize = qrCode.size <= SMALL_QR_SIZE ? FINDER_PATTERN_SIZE : FINDER_PATTERN_SIZE + 2;\n const logoAreaStart = (qrCode.size - logoAreaSize) / 2;\n return qrCode.modules.map((row, y) =>\n row.map(\n (pixel, x) =>\n pixel &&\n !(\n x >= logoAreaStart &&\n x < logoAreaStart + logoAreaSize &&\n y >= logoAreaStart &&\n y < logoAreaStart + logoAreaSize\n ),\n ),\n );\n}\n\nfunction renderModules(qrCode: QrCode, options: RequiredQrOptions): string {\n return extractFigures(getVisibleModules(qrCode, options.isShowLogo))\n .filter((figure) => !isFinderPattern(figure, qrCode.size))\n .map(\n (figure) => `\n <path\n d=\"${figureToSvgPath(figure)}\"\n fill=\"${options.foregroundColor}\"\n fill-rule=\"evenodd\"\n />`,\n )\n .join('');\n}\n\nfunction renderFinderPatterns(size: number, options: RequiredQrOptions): string[] {\n const pointPosition = (size - FINDER_PATTERN_SIZE) * TILE_SIZE;\n return [\n `<use fill-rule=\"evenodd\" transform=\"translate(0,0)\" xlink:href=\"#point-${options.suffix}\"/>`,\n `<use fill-rule=\"evenodd\" transform=\"translate(${pointPosition},0)\" xlink:href=\"#point-${options.suffix}\"/>`,\n `<use fill-rule=\"evenodd\" transform=\"translate(0,${pointPosition})\" xlink:href=\"#point-${options.suffix}\"/>`,\n ];\n}\n\nfunction renderLogo(size: number, options: RequiredQrOptions): string {\n let scale = '';\n let position =\n ((size - FINDER_PATTERN_SIZE * 3) / 2) * TILE_SIZE + TILE_SIZE * FINDER_PATTERN_SIZE - 10;\n if (size <= SMALL_QR_SIZE) {\n scale = 'scale(0.85)';\n position += 50;\n }\n\n if (!options.logoData) {\n return `\n <use style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n fill=\"none\"\n fill-rule=\"evenodd\"\n transform=\"translate(${position},${position}) ${scale}\" xlink:href=\"#vk_logo-${options.suffix}\"\n />\n `;\n }\n\n return `\n <image\n preserveAspectRatio=\"xMidYMid slice\" clip-path=\"url(#logo-mask-${options.suffix})\"\n style=\"width: 750px; height: 750px;\" width=\"750\" height=\"750\"\n transform=\"translate(${position},${position}) ${scale}\"\n xlink:href=\"${options.logoData}\"\n />\n `;\n}\n\nfunction getBackgroundLayout(size: number, options: RequiredQrOptions): BackgroundLayout {\n const contentSize = TILE_SIZE * size;\n if (!options.isShowBackground) {\n return { size: contentSize, padding: 0, radius: 0, hideQr: false };\n }\n\n const frameWidth = Math.min(options.backgroundPadding, options.qrSize / 2);\n const contentWidth = options.qrSize - frameWidth * 2;\n const hideQr = contentWidth <= 0;\n const backgroundSize = hideQr ? contentSize : (contentSize * options.qrSize) / contentWidth;\n const padding = (backgroundSize - contentSize) / 2;\n const radius =\n (Math.min(options.backgroundRadius, options.qrSize / 2) / options.qrSize) * backgroundSize;\n\n return { size: backgroundSize, padding, radius, hideQr };\n}\n\nfunction renderBackground(layout: BackgroundLayout, options: RequiredQrOptions): string {\n if (!options.isShowBackground) return '';\n\n const { size, padding, radius } = layout;\n return `\n <rect\n x=\"${-padding}\"\n y=\"${-padding}\"\n width=\"${size}\"\n height=\"${size}\"\n rx=\"${radius}\"\n fill=\"${options.backgroundColor}\"\n />`;\n}\n\nfunction renderDefinitions(options: RequiredQrOptions): string {\n return `<defs>\n <g\n id=\"point-${options.suffix}\"\n fill=\"${options.foregroundColor}\"\n >\n <rect width=\"300\" height=\"300\" x=\"200\" y=\"200\" rx=\"${FINDER_CORNER_RADIUS}\" />\n <rect width=\"600\" height=\"600\" x=\"50\" y=\"50\" rx=\"${FINDER_CORNER_RADIUS * 2}\" stroke-width=\"100\" fill=\"none\" stroke=\"${options.foregroundColor}\" />\n </g>\n <g id=\"vk_logo-${options.suffix}\">\n <path\n fill=\"${options.logoColor}\"\n d=\"M83.3334 363.333C83.3334 231.34 83.3334 165.343 124.338 124.338C165.343 83.3333 231.34 \\\n 83.3333 363.333 83.3333H386.667C518.66 83.3333 584.657 83.3333 625.662 124.338C666.667 165.343 \\\n 666.667 231.34 666.667 363.333V386.667C666.667 518.66 666.667 584.657 625.662 625.662C584.657 \\\n 666.667 518.66 666.667 386.667 666.667H363.333C231.34 666.667 165.343 666.667 124.338 625.662C83.3334 \\\n 584.657 83.3334 518.66 83.3334 386.667V363.333Z\"\n />\n <path\n fill=\"#FFF\"\n d=\"M394.907 508.681C263.293 508.681 183.442 417.365 180.313 265.625H246.972C249.05 377.09 \\\n 299.763 424.323 338.638 434.036V265.625H402.519V361.82C440.016 357.664 479.264 313.909 \\\n 492.456 265.625H555.333C545.27 325 502.543 368.754 472.353 386.803C502.566 401.395 551.177 \\\n 439.593 569.926 508.681H500.815C486.222 462.498 450.476 426.728 402.542 421.872V508.681H394.907Z\"\n />\n </g>\n <clipPath id=\"logo-mask-${options.suffix}\">\n <rect x=\"0\" y=\"0\" width=\"750\" height=\"750\" />\n </clipPath>\n </defs>`;\n}\n","/*\n * QR Code generator library (TypeScript)\n *\n * Copyright (c) Project Nayuki. (MIT License)\n * https://www.nayuki.io/page/qr-code-generator-library\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n * - The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * - The Software is provided \"as is\", without warranty of any kind, express or\n * implied, including but not limited to the warranties of merchantability,\n * fitness for a particular purpose and noninfringement. In no event shall the\n * authors or copyright holders be liable for any claim, damages or other\n * liability, whether in an action of contract, tort or otherwise, arising from,\n * out of or in connection with the Software or the use or other dealings in the\n * Software.\n */\n\ntype bit = number;\ntype byte = number;\ntype int = number;\n\n/*---- Public helper constants ----*/\n\n/*\n * The error correction level in a QR Code symbol.\n */\nexport const QrCodeEcc = {\n LOW: { ordinal: 0, formatBits: 1 } as const, // The QR Code can tolerate about 7% erroneous codewords\n MEDIUM: { ordinal: 1, formatBits: 0 } as const, // The QR Code can tolerate about 15% erroneous codewords\n QUARTILE: { ordinal: 2, formatBits: 3 } as const, // The QR Code can tolerate about 25% erroneous codewords\n HIGH: { ordinal: 3, formatBits: 2 } as const, // The QR Code can tolerate about 30% erroneous codewords\n} as const;\n\nexport type QrCodeEccValue = (typeof QrCodeEcc)[keyof typeof QrCodeEcc];\n\n/*\n * Describes how a segment's data bits are interpreted.\n */\nexport const QrSegmentMode = {\n NUMERIC: { modeBits: 0x1, numBitsCharCount: [10, 12, 14] as const },\n ALPHANUMERIC: { modeBits: 0x2, numBitsCharCount: [9, 11, 13] as const },\n BYTE: { modeBits: 0x4, numBitsCharCount: [8, 16, 16] as const },\n KANJI: { modeBits: 0x8, numBitsCharCount: [8, 10, 12] as const },\n ECI: { modeBits: 0x7, numBitsCharCount: [0, 0, 0] as const },\n} as const;\n\nexport type QrSegmentModeValue = (typeof QrSegmentMode)[keyof typeof QrSegmentMode];\n\nfunction numCharCountBits(mode: QrSegmentModeValue, ver: int): int {\n return mode.numBitsCharCount[Math.floor((ver + 7) / 17)];\n}\n\n/*---- QR Code result type ----*/\n\n/*\n * A QR Code symbol, which is a type of two-dimension barcode.\n * Invented by Denso Wave and described in the ISO/IEC 18004 standard.\n * Represents an immutable square grid of black and white cells.\n */\nexport interface QrCode {\n /** The version number of this QR Code, between 1 and 40 (inclusive). */\n readonly version: int;\n /** The error correction level used in this QR Code. */\n readonly errorCorrectionLevel: QrCodeEccValue;\n /** The width and height of this QR Code, measured in modules, between 21 and 177 (inclusive). */\n readonly size: int;\n /** The index of the mask pattern used in this QR Code, between 0 and 7 (inclusive). */\n readonly mask: int;\n /** The modules of this QR Code (false = white, true = black). */\n readonly modules: boolean[][];\n}\n\n/*---- QR Code factory function (mid level) ----*/\n\n// Returns a QR Code representing the given segments with the given encoding parameters.\n// The smallest possible QR Code version within the given range is automatically\n// chosen for the output. Iff boostEcl is true, then the ECC level of the result\n// may be higher than the ecl argument if it can be done without increasing the\n// version. The mask number is either between 0 to 7 (inclusive) to force that\n// mask, or -1 to automatically choose an appropriate mask (which may be slow).\n// This function allows the user to create a custom sequence of segments that switches\n// between modes (such as alphanumeric and byte) to encode text in less space.\n// This is a mid-level API; the high-level API is encodeText() and encodeBinary().\nexport function encodeSegments(\n segs: QrSegment[],\n ecl: QrCodeEccValue,\n minVersion: int = 1,\n maxVersion: int = 40,\n mask: int = -1,\n boostEcl: boolean = true,\n): QrCode {\n if (\n !(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) ||\n mask < -1 ||\n mask > 7\n )\n throw 'Invalid value';\n\n // Find the minimal version number to use\n let version: int;\n let dataUsedBits: int;\n for (version = minVersion; ; version++) {\n const dataCapacityBits: int = getNumDataCodewords(version, ecl) * 8; // Number of data bits available\n const usedBits: number = getTotalBits(segs, version);\n if (usedBits <= dataCapacityBits) {\n dataUsedBits = usedBits;\n break; // This version number is found to be suitable\n }\n if (version >= maxVersion)\n // All versions in the range could not fit the given data\n throw 'Data too long';\n }\n\n // Increase the error correction level while the data still fits in the current version number\n let finalEcl = ecl;\n for (const newEcl of [QrCodeEcc.MEDIUM, QrCodeEcc.QUARTILE, QrCodeEcc.HIGH]) {\n // From low to high\n if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8) finalEcl = newEcl;\n }\n\n // Concatenate all segments to create the data bit string\n const bb = createBitBuffer();\n for (const seg of segs) {\n bb.appendBits(seg.mode.modeBits, 4);\n bb.appendBits(seg.numChars, numCharCountBits(seg.mode, version));\n for (const b of seg.getData()) bb.array.push(b);\n }\n if (bb.array.length !== dataUsedBits) throw 'Assertion error';\n\n // Add terminator and pad up to a byte if applicable\n const dataCapacityBits: int = getNumDataCodewords(version, finalEcl) * 8;\n if (bb.array.length > dataCapacityBits) throw 'Assertion error';\n bb.appendBits(0, Math.min(4, dataCapacityBits - bb.array.length));\n bb.appendBits(0, (8 - (bb.array.length % 8)) % 8);\n if (bb.array.length % 8 !== 0) throw 'Assertion error';\n\n // Pad with alternating bytes until data capacity is reached\n for (let padByte = 0xec; bb.array.length < dataCapacityBits; padByte ^= 0xec ^ 0x11)\n bb.appendBits(padByte, 8);\n\n // Pack bits into bytes in big endian\n const dataCodewords: byte[] = [];\n while (dataCodewords.length * 8 < bb.array.length) dataCodewords.push(0);\n bb.array.forEach((b: bit, i: int) => {\n dataCodewords[i >>> 3] |= b << (7 - (i & 7));\n });\n\n // Create the QR Code object\n return createQrCode(version, finalEcl, dataCodewords, mask);\n}\n\n/*---- Private QR Code creation function ----*/\n\n// Creates a new QR Code with the given version number,\n// error correction level, data codeword bytes, and mask number.\nfunction createQrCode(\n version: int,\n errorCorrectionLevel: QrCodeEccValue,\n dataCodewords: byte[],\n mask: int,\n): QrCode {\n // Check scalar arguments\n if (version < MIN_VERSION || version > MAX_VERSION) throw 'Version value out of range';\n if (mask < -1 || mask > 7) throw 'Mask value out of range';\n const size = version * 4 + 17;\n\n // Initialize both grids to be size*size arrays of Boolean false\n const row: boolean[] = [];\n for (let i = 0; i < size; i++) row.push(false);\n const modules: boolean[][] = [];\n const isFunction: boolean[][] = [];\n for (let i = 0; i < size; i++) {\n modules.push(row.slice()); // Initially all white\n isFunction.push(row.slice());\n }\n\n // Helper to set function module\n const setFunctionModule = (x: int, y: int, isBlack: boolean): void => {\n modules[y][x] = isBlack;\n isFunction[y][x] = true;\n };\n\n // Draw horizontal and vertical timing patterns\n for (let i = 0; i < size; i++) {\n setFunctionModule(6, i, i % 2 === 0);\n setFunctionModule(i, 6, i % 2 === 0);\n }\n\n // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)\n const drawFinderPattern = (x: int, y: int): void => {\n for (let dy = -4; dy <= 4; dy++) {\n for (let dx = -4; dx <= 4; dx++) {\n const dist: int = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm\n const xx: int = x + dx;\n const yy: int = y + dy;\n if (0 <= xx && xx < size && 0 <= yy && yy < size)\n setFunctionModule(xx, yy, dist !== 2 && dist !== 4);\n }\n }\n };\n drawFinderPattern(3, 3);\n drawFinderPattern(size - 4, 3);\n drawFinderPattern(3, size - 4);\n\n // Draw numerous alignment patterns\n const alignPatPos: int[] = getAlignmentPatternPositions(version, size);\n const numAlign: int = alignPatPos.length;\n for (let i = 0; i < numAlign; i++) {\n for (let j = 0; j < numAlign; j++) {\n // Don't draw on the three finder corners\n if (\n !(\n (i === 0 && j === 0) ||\n (i === 0 && j === numAlign - 1) ||\n (i === numAlign - 1 && j === 0)\n )\n ) {\n const drawAlignmentPattern = (x: int, y: int): void => {\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++)\n setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n }\n };\n drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);\n }\n }\n }\n\n // Draw configuration data\n const drawFormatBits = (ecl: QrCodeEccValue, msk: int): void => {\n // Calculate error correction code and pack bits\n const data: int = (ecl.formatBits << 3) | msk; // errCorrLvl is uint2, mask is uint3\n let rem: int = data;\n for (let i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >>> 9) * 0x537);\n const bits = ((data << 10) | rem) ^ 0x5412; // uint15\n if (bits >>> 15 !== 0) throw 'Assertion error';\n\n // Draw first copy\n for (let i = 0; i <= 5; i++) setFunctionModule(8, i, getBit(bits, i));\n setFunctionModule(8, 7, getBit(bits, 6));\n setFunctionModule(8, 8, getBit(bits, 7));\n setFunctionModule(7, 8, getBit(bits, 8));\n for (let i = 9; i < 15; i++) setFunctionModule(14 - i, 8, getBit(bits, i));\n\n // Draw second copy\n for (let i = 0; i < 8; i++) setFunctionModule(size - 1 - i, 8, getBit(bits, i));\n for (let i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, getBit(bits, i));\n setFunctionModule(8, size - 8, true); // Always black\n };\n drawFormatBits(errorCorrectionLevel, 0); // Dummy mask value; overwritten later\n\n // Draw version\n if (version >= 7) {\n // Calculate error correction code and pack bits\n let rem: int = version; // version is uint6, in the range [7, 40]\n for (let i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);\n const bits: int = (version << 12) | rem; // uint18\n if (bits >>> 18 !== 0) throw 'Assertion error';\n\n // Draw two copies\n for (let i = 0; i < 18; i++) {\n const color: boolean = getBit(bits, i);\n const a: int = size - 11 + (i % 3);\n const b: int = Math.floor(i / 3);\n setFunctionModule(a, b, color);\n setFunctionModule(b, a, color);\n }\n }\n\n // Compute ECC, draw modules\n const allCodewords: byte[] = addEccAndInterleave(version, errorCorrectionLevel, dataCodewords);\n\n // Draw codewords\n if (allCodewords.length !== Math.floor(getNumRawDataModules(version) / 8))\n throw 'Invalid argument';\n let bitIndex: int = 0; // Bit index into the data\n // Do the funny zigzag scan\n for (let right = size - 1; right >= 1; right -= 2) {\n // Index of right column in each column pair\n if (right === 6) right = 5;\n for (let vert = 0; vert < size; vert++) {\n // Vertical counter\n for (let j = 0; j < 2; j++) {\n const x: int = right - j; // Actual x coordinate\n const upward: boolean = ((right + 1) & 2) === 0;\n const y: int = upward ? size - 1 - vert : vert; // Actual y coordinate\n if (!isFunction[y][x] && bitIndex < allCodewords.length * 8) {\n modules[y][x] = getBit(allCodewords[bitIndex >>> 3], 7 - (bitIndex & 7));\n bitIndex++;\n }\n // If this QR Code has any remainder bits (0 to 7), they were assigned as\n // 0/false/white by the constructor and are left unchanged by this method\n }\n }\n }\n if (bitIndex !== allCodewords.length * 8) throw 'Assertion error';\n\n // Do masking\n let finalMask = mask;\n if (finalMask === -1) {\n // Automatically choose best mask\n let minPenalty: int = 1000000000;\n for (let i = 0; i < 8; i++) {\n applyMask(modules, isFunction, size, i);\n drawFormatBits(errorCorrectionLevel, i);\n const penalty: int = getPenaltyScore(modules, size);\n if (penalty < minPenalty) {\n finalMask = i;\n minPenalty = penalty;\n }\n applyMask(modules, isFunction, size, i); // Undoes the mask due to XOR\n }\n }\n if (finalMask < 0 || finalMask > 7) throw 'Assertion error';\n applyMask(modules, isFunction, size, finalMask);\n // Redraw format bits with final mask\n // We need to update format bits, but modules are already set\n // So we need to redraw them\n {\n const data: int = (errorCorrectionLevel.formatBits << 3) | finalMask;\n let rem: int = data;\n for (let i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >>> 9) * 0x537);\n const bits = ((data << 10) | rem) ^ 0x5412;\n if (bits >>> 15 !== 0) throw 'Assertion error';\n for (let i = 0; i <= 5; i++) modules[i][8] = getBit(bits, i);\n modules[7][8] = getBit(bits, 6);\n modules[8][8] = getBit(bits, 7);\n modules[8][7] = getBit(bits, 8);\n for (let i = 9; i < 15; i++) modules[8][14 - i] = getBit(bits, i);\n for (let i = 0; i < 8; i++) modules[8][size - 1 - i] = getBit(bits, i);\n for (let i = 8; i < 15; i++) modules[size - 15 + i][8] = getBit(bits, i);\n modules[size - 8][8] = true; // Always black\n }\n\n return {\n version,\n errorCorrectionLevel,\n size,\n mask: finalMask,\n modules,\n };\n}\n\n/*---- Private helper functions ----*/\n\n// Returns an ascending list of positions of alignment patterns for this version number.\n// Each position is in the range [0,177), and are used on both the x and y axes.\nfunction getAlignmentPatternPositions(version: int, size: int): int[] {\n if (version === 1) return [];\n else {\n const numAlign: int = Math.floor(version / 7) + 2;\n const step: int = version === 32 ? 26 : Math.ceil((size - 13) / (numAlign * 2 - 2)) * 2;\n const result: int[] = [6];\n for (let pos = size - 7; result.length < numAlign; pos -= step) result.splice(1, 0, pos);\n return result;\n }\n}\n\n// XORs the codeword modules in this QR Code with the given mask pattern.\n// The function modules must be marked and the codeword bits must be drawn\n// before masking. Due to the arithmetic of XOR, calling applyMask() with\n// the same mask value a second time will undo the mask. A final well-formed\n// QR Code needs exactly one (not zero, two, etc.) mask applied.\nfunction applyMask(modules: boolean[][], isFunction: boolean[][], size: int, mask: int): void {\n if (mask < 0 || mask > 7) throw 'Mask value out of range';\n for (let y = 0; y < size; y++) {\n for (let x = 0; x < size; x++) {\n let invert: boolean;\n switch (mask) {\n case 0:\n invert = (x + y) % 2 === 0;\n break;\n case 1:\n invert = y % 2 === 0;\n break;\n case 2:\n invert = x % 3 === 0;\n break;\n case 3:\n invert = (x + y) % 3 === 0;\n break;\n case 4:\n invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;\n break;\n case 5:\n invert = ((x * y) % 2) + ((x * y) % 3) === 0;\n break;\n case 6:\n invert = (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;\n break;\n case 7:\n invert = (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;\n break;\n default:\n throw 'Assertion error';\n }\n if (!isFunction[y][x] && invert) modules[y][x] = !modules[y][x];\n }\n }\n}\n\n// Calculates and returns the penalty score based on state of this QR Code's current modules.\n// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.\nfunction getPenaltyScore(modules: boolean[][], size: int): int {\n let result: int = 0;\n\n // Adjacent modules in row having same color, and finder-like patterns\n for (let y = 0; y < size; y++) {\n const runHistory = [0, 0, 0, 0, 0, 0, 0];\n let color = false;\n let runX = 0;\n for (let x = 0; x < size; x++) {\n if (modules[y][x] === color) {\n runX++;\n if (runX === 5) result += PENALTY_N1;\n else if (runX > 5) result++;\n } else {\n addRunToHistory(runX, runHistory);\n if (!color && hasFinderLikePattern(runHistory)) result += PENALTY_N3;\n color = modules[y][x];\n runX = 1;\n }\n }\n addRunToHistory(runX, runHistory);\n if (color) addRunToHistory(0, runHistory); // Dummy run of white\n if (hasFinderLikePattern(runHistory)) result += PENALTY_N3;\n }\n // Adjacent modules in column having same color, and finder-like patterns\n for (let x = 0; x < size; x++) {\n const runHistory = [0, 0, 0, 0, 0, 0, 0];\n let color = false;\n let runY = 0;\n for (let y = 0; y < size; y++) {\n if (modules[y][x] === color) {\n runY++;\n if (runY === 5) result += PENALTY_N1;\n else if (runY > 5) result++;\n } else {\n addRunToHistory(runY, runHistory);\n if (!color && hasFinderLikePattern(runHistory)) result += PENALTY_N3;\n color = modules[y][x];\n runY = 1;\n }\n }\n addRunToHistory(runY, runHistory);\n if (color) addRunToHistory(0, runHistory); // Dummy run of white\n if (hasFinderLikePattern(runHistory)) result += PENALTY_N3;\n }\n\n // 2*2 blocks of modules having same color\n for (let y = 0; y < size - 1; y++) {\n for (let x = 0; x < size - 1; x++) {\n const color: boolean = modules[y][x];\n if (\n color === modules[y][x + 1] &&\n color === modules[y + 1][x] &&\n color === modules[y + 1][x + 1]\n )\n result += PENALTY_N2;\n }\n }\n\n // Balance of black and white modules\n let black: int = 0;\n for (const row of modules) {\n for (const color of row) {\n if (color) black++;\n }\n }\n const total: int = size * size; // Note that size is odd, so black/total != 1/2\n // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)%\n const k: int = Math.ceil(Math.abs(black * 20 - total * 10) / total) - 1;\n result += k * PENALTY_N4;\n return result;\n}\n\n// Inserts the given value to the front of the given array, which shifts over the\n// existing values and deletes the last value. A helper function for getPenaltyScore().\nfunction addRunToHistory(run: int, history: int[]): void {\n history.pop();\n history.unshift(run);\n}\n\n// Tests whether the given run history has the pattern of ratio 1:1:3:1:1 in the middle, and\n// surrounded by at least 4 on either or both ends. A helper function for getPenaltyScore().\n// Must only be called immediately after a run of white modules has ended.\nfunction hasFinderLikePattern(runHistory: int[]): boolean {\n const n: int = runHistory[1];\n return (\n n > 0 &&\n runHistory[2] === n &&\n runHistory[4] === n &&\n runHistory[5] === n &&\n runHistory[3] === n * 3 &&\n Math.max(runHistory[0], runHistory[6]) >= n * 4\n );\n}\n\n// Returns a new byte string representing the given data with the appropriate error correction\n// codewords appended to it, based on this object's version and error correction level.\nfunction addEccAndInterleave(version: int, ecl: QrCodeEccValue, data: byte[]): byte[] {\n if (data.length !== getNumDataCodewords(version, ecl)) throw 'Invalid argument';\n\n // Calculate parameter numbers\n const numBlocks: int = NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][version];\n const blockEccLen: int = ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][version];\n const rawCodewords: int = Math.floor(getNumRawDataModules(version) / 8);\n const numShortBlocks: int = numBlocks - (rawCodewords % numBlocks);\n const shortBlockLen: int = Math.floor(rawCodewords / numBlocks);\n\n // Split data into blocks and append ECC to each block\n const blocks: byte[][] = [];\n const rs = createReedSolomonGenerator(blockEccLen);\n for (let i = 0, k = 0; i < numBlocks; i++) {\n const dat: byte[] = data.slice(\n k,\n k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1),\n );\n k += dat.length;\n const ecc: byte[] = rs.getRemainder(dat);\n if (i < numShortBlocks) dat.push(0);\n blocks.push(dat.concat(ecc));\n }\n\n // Interleave (not concatenate) the bytes from every block into a single sequence\n const result: byte[] = [];\n for (let i = 0; i < blocks[0].length; i++) {\n for (let j = 0; j < blocks.length; j++) {\n // Skip the padding byte in short blocks\n if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks) result.push(blocks[j][i]);\n }\n }\n if (result.length !== rawCodewords) throw 'Assertion error';\n return result;\n}\n\n// Returns the number of data bits that can be stored in a QR Code of the given version number, after\n// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.\n// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.\nfunction getNumRawDataModules(ver: int): int {\n if (ver < MIN_VERSION || ver > MAX_VERSION) throw 'Version number out of range';\n let result: int = (16 * ver + 128) * ver + 64;\n if (ver >= 2) {\n const numAlign: int = Math.floor(ver / 7) + 2;\n result -= (25 * numAlign - 10) * numAlign - 55;\n if (ver >= 7) result -= 36;\n }\n return result;\n}\n\n// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any\n// QR Code of the given version number and error correction level, with remainder bits discarded.\n// This stateless pure function could be implemented as a (40*4)-cell lookup table.\nfunction getNumDataCodewords(ver: int, ecl: QrCodeEccValue): int {\n return (\n Math.floor(getNumRawDataModules(ver) / 8) -\n ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]\n );\n}\n\n// Returns true iff the i'th bit of x is set to 1.\nfunction getBit(x: int, i: int): boolean {\n return ((x >>> i) & 1) !== 0;\n}\n\n/*---- Data segment type and factory functions ----*/\n\n/*\n * A segment of character/binary/control data in a QR Code symbol.\n * The mid-level way to create a segment is to take the payload data\n * and call a factory function such as makeNumeric().\n * The low-level way to create a segment is to custom-make the bit buffer\n * and call createQrSegment() with appropriate values.\n * This segment imposes no length restrictions, but QR Codes have restrictions.\n * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.\n * Any segment longer than this is meaningless for the purpose of generating QR Codes.\n */\nexport interface QrSegment {\n /** The mode indicator of this segment. */\n readonly mode: QrSegmentModeValue;\n /** The length of this segment's unencoded data. Measured in characters for\n * numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.\n * Always zero or positive. Not the same as the data's bit length.\n */\n readonly numChars: int;\n /** Returns a new copy of the data bits of this segment. */\n getData(): bit[];\n}\n\n// Creates a new QR Code segment with the given attributes and data.\n// The character count (numChars) must agree with the mode and the bit buffer length,\n// but the constraint isn't checked. The given bit buffer is cloned and stored.\nfunction createQrSegment(mode: QrSegmentModeValue, numChars: int, bitData: bit[]): QrSegment {\n if (numChars < 0) throw 'Invalid argument';\n const data = bitData.slice(); // Make defensive copy\n return {\n mode,\n numChars,\n getData: () => data.slice(), // Make defensive copy\n };\n}\n\n// Returns a segment representing the given binary data encoded in\n// byte mode. All input byte arrays are acceptable. Any text string\n// can be converted to UTF-8 bytes and encoded as a byte mode segment.\nfunction makeBytes(data: byte[]): QrSegment {\n const bb = createBitBuffer();\n for (const b of data) bb.appendBits(b, 8);\n return createQrSegment(QrSegmentMode.BYTE, data.length, bb.array);\n}\n\n// Returns a segment representing the given string of decimal digits encoded in numeric mode.\nfunction makeNumeric(digits: string): QrSegment {\n if (!NUMERIC_REGEX.test(digits)) throw 'String contains non-numeric characters';\n const bb = createBitBuffer();\n for (let i = 0; i < digits.length; ) {\n // Consume up to 3 digits per iteration\n const n: int = Math.min(digits.length - i, 3);\n bb.appendBits(parseInt(digits.substr(i, n), 10), n * 3 + 1);\n i += n;\n }\n return createQrSegment(QrSegmentMode.NUMERIC, digits.length, bb.array);\n}\n\n// Returns a segment representing the given text string encoded in alphanumeric mode.\n// The characters allowed are: 0 to 9, A to Z (uppercase only), space,\n// dollar, percent, asterisk, plus, hyphen, period, slash, colon.\nfunction makeAlphanumeric(text: string): QrSegment {\n if (!ALPHANUMERIC_REGEX.test(text))\n throw 'String contains unencodable characters in alphanumeric mode';\n const bb = createBitBuffer();\n let i: int;\n for (i = 0; i + 2 <= text.length; i += 2) {\n // Process groups of 2\n let temp: int = ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;\n temp += ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));\n bb.appendBits(temp, 11);\n }\n if (i < text.length)\n // 1 character remaining\n bb.appendBits(ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6);\n return createQrSegment(QrSegmentMode.ALPHANUMERIC, text.length, bb.array);\n}\n\n// Returns a new mutable list of zero or more segments to represent the given Unicode text string.\n// The result may use various segment modes and switch modes to optimize the length of the bit stream.\nexport function makeSegments(text: string): QrSegment[] {\n // Select the most efficient segment encoding automatically\n if (text === '') return [];\n else if (NUMERIC_REGEX.test(text)) return [makeNumeric(text)];\n else if (ALPHANUMERIC_REGEX.test(text)) return [makeAlphanumeric(text)];\n else return [makeBytes(toUtf8ByteArray(text))];\n}\n\n// Calculates and returns the number of bits needed to encode the given segments at\n// the given version. The result is infinity if a segment has too many characters to fit its length field.\nfunction getTotalBits(segs: QrSegment[], version: int): number {\n let result: number = 0;\n for (const seg of segs) {\n const ccbits: int = numCharCountBits(seg.mode, version);\n if (seg.numChars >= 1 << ccbits) return Infinity; // The segment's length doesn't fit the field's bit width\n result += 4 + ccbits + seg.getData().length;\n }\n return result;\n}\n\n// Returns a new array of bytes representing the given string encoded in UTF-8.\nfunction toUtf8ByteArray(str: string): byte[] {\n str = encodeURI(str);\n const result: byte[] = [];\n for (let i = 0; i < str.length; i++) {\n if (str.charAt(i) !== '%') result.push(str.charCodeAt(i));\n else {\n result.push(parseInt(str.substr(i + 1, 2), 16));\n i += 2;\n }\n }\n return result;\n}\n\n/*---- Private helper: BitBuffer ----*/\n\n/*\n * An appendable sequence of bits (0s and 1s). Mainly used by QrSegment.\n */\ninterface BitBuffer {\n array: bit[];\n appendBits(val: int, len: int): void;\n}\n\nfunction createBitBuffer(): BitBuffer {\n const array: bit[] = [];\n return {\n array,\n appendBits(val: int, len: int): void {\n if (len < 0 || len > 31 || val >>> len !== 0) throw 'Value out of range';\n for (let i = len - 1; i >= 0; i--)\n // Append bit by bit\n array.push((val >>> i) & 1);\n },\n };\n}\n\n/*---- Private helper: ReedSolomonGenerator ----*/\n\n/*\n * Computes the Reed-Solomon error correction codewords for a sequence of data codewords\n * at a given degree. Objects are immutable, and the state only depends on the degree.\n * This exists because each data block in a QR Code shares the same the divisor polynomial.\n */\ninterface ReedSolomonGenerator {\n getRemainder(data: byte[]): byte[];\n}\n\nfunction createReedSolomonGenerator(degree: int): ReedSolomonGenerator {\n if (degree < 1 || degree > 255) throw 'Degree out of range';\n const coefficients: byte[] = [];\n\n // Start with the monomial x^0\n for (let i = 0; i < degree - 1; i++) coefficients.push(0);\n coefficients.push(1);\n\n // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}),\n // drop the highest term, and store the rest of the coefficients in order of descending powers.\n // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D).\n let root = 1;\n for (let i = 0; i < degree; i++) {\n // Multiply the current product by (x - r^i)\n for (let j = 0; j < coefficients.length; j++) {\n coefficients[j] = rsMultiply(coefficients[j], root);\n if (j + 1 < coefficients.length) coefficients[j] ^= coefficients[j + 1];\n }\n root = rsMultiply(root, 0x02);\n }\n\n return {\n getRemainder(data: byte[]): byte[] {\n // Compute the remainder by performing polynomial division\n const result: byte[] = coefficients.map(() => 0);\n for (const b of data) {\n const factor: byte = b ^ (result.shift() as byte);\n result.push(0);\n coefficients.forEach((coef, i) => {\n result[i] ^= rsMultiply(coef, factor);\n });\n }\n return result;\n },\n };\n}\n\n// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result\n// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.\nfunction rsMultiply(x: byte, y: byte): byte {\n if (x >>> 8 !== 0 || y >>> 8 !== 0) throw 'Byte out of range';\n // Russian peasant multiplication\n let z: int = 0;\n for (let i = 7; i >= 0; i--) {\n z = (z << 1) ^ ((z >>> 7) * 0x11d);\n z ^= ((y >>> i) & 1) * x;\n }\n if (z >>> 8 !== 0) throw 'Assertion error';\n return z as byte;\n}\n\n/*---- Constants and tables ----*/\n\n// The minimum version number supported in the QR Code Model 2 standard.\nconst MIN_VERSION: int = 1;\n// The maximum version number supported in the QR Code Model 2 standard.\nconst MAX_VERSION: int = 40;\n\n// For use in getPenaltyScore(), when evaluating which mask is best.\nconst PENALTY_N1: int = 3;\nconst PENALTY_N2: int = 3;\nconst PENALTY_N3: int = 40;\nconst PENALTY_N4: int = 10;\n\nconst ECC_CODEWORDS_PER_BLOCK: int[][] = [\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //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\n [\n -1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30,\n 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ], // Low\n [\n -1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28,\n 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ], // Medium\n [\n -1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30,\n 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ], // Quartile\n [\n -1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ], // High\n];\n\nconst NUM_ERROR_CORRECTION_BLOCKS: int[][] = [\n // Version: (note that index 0 is for padding, and is set to an illegal value)\n //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\n [\n -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,\n 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25,\n ], // Low\n [\n -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,\n 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49,\n ], // Medium\n [\n -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,\n 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68,\n ], // Quartile\n [\n -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,\n 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81,\n ], // High\n];\n\n// Describes precisely all strings that are encodable in numeric mode. To test\n// whether a string s is encodable: let ok: boolean = NUMERIC_REGEX.test(s);\n// A string is encodable iff each character is in the range 0 to 9.\nconst NUMERIC_REGEX: RegExp = /^[0-9]*$/;\n\n// Describes precisely all strings that are encodable in alphanumeric mode. To test\n// whether a string s is encodable: let ok: boolean = ALPHANUMERIC_REGEX.test(s);\n// A string is encodable iff each character is in the following set: 0 to 9, A to Z\n// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.\nconst ALPHANUMERIC_REGEX: RegExp = /^[A-Z0-9 $%*+./:-]*$/;\n\n// The set of all legal characters in alphanumeric mode,\n// where each character value maps to the index in the string.\nconst ALPHANUMERIC_CHARSET: string = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';\n","import { convertSegmentsToSvgString, INC_TILE_SIZE } from './svg.ts';\nimport { makeSegments, encodeSegments, QrCodeEcc } from './qr.ts';\nimport type { QrOptions, RequiredQrOptions } from './types.ts';\nimport { BACKGROUND_PADDING, BACKGROUND_RADIUS } from './constants.ts';\n\n/** Default width and height of QR code */\nconst DEFAULT_SIZE = 128;\n\n/** Default background color of QR code*/\nconst BACKGROUND_COLOR_DEFAULT = '#ffffff';\n\n/** Default foreground color */\nconst FOREGROUND_COLOR_DEFAULT = '#000000';\n\n/** Default logo color */\nconst LOGO_COLOR_DEFAULT = '#07f';\n\n/**\n * Generates SVG QR code by a text\n * @param text String to encode\n * @param options QR code options\n */\nexport function createQR(text: string, options?: QrOptions): string;\n\n/**\n * Legacy interface\n * @deprecated\n * @param text String to encode\n * @param qrSize Size of QR code\n * @param className SVG element class name\n * @param options Options of the QR code\n */\nexport function createQR(\n text: string,\n qrSize: number,\n className: string,\n options?: QrOptions,\n): string;\n\n/**\n * Implementation\n */\nexport function createQR(\n text: string,\n qrSizeOrOptions?: number | QrOptions,\n classNameLegacy?: string,\n legacyOptions?: QrOptions,\n): string {\n if (typeof text !== 'string') {\n throw new TypeError('Enter text for encoding');\n }\n\n // Legacy interface resolve\n const options: QrOptions = {\n ...(typeof qrSizeOrOptions === 'object' && qrSizeOrOptions !== null ? qrSizeOrOptions : {}),\n ...(typeof legacyOptions === 'object' && legacyOptions !== null ? legacyOptions : {}),\n qrSize:\n typeof qrSizeOrOptions === 'object' &&\n qrSizeOrOptions !== null &&\n typeof qrSizeOrOptions.qrSize === 'number'\n ? qrSizeOrOptions.qrSize\n : (qrSizeOrOptions as number),\n className:\n typeof qrSizeOrOptions === 'object' &&\n qrSizeOrOptions !== null &&\n typeof qrSizeOrOptions.className === 'string'\n ? qrSizeOrOptions.className\n : classNameLegacy,\n };\n\n // ECC levels mapping\n const eccLevels = [QrCodeEcc.LOW, QrCodeEcc.MEDIUM, QrCodeEcc.QUARTILE, QrCodeEcc.HIGH];\n\n // Fallback undefined options\n const fallbackOptions: RequiredQrOptions = {\n qrSize: typeof options.qrSize === 'number' ? options.qrSize : DEFAULT_SIZE,\n className: typeof options.className === 'string' ? options.className : classNameLegacy || '',\n isShowLogo: !!options.isShowLogo || false,\n isShowBackground: !!options.isShowBackground || false,\n foregroundColor:\n typeof options.foregroundColor === 'string'\n ? options.foregroundColor\n : FOREGROUND_COLOR_DEFAULT,\n backgroundColor:\n typeof options.backgroundColor === 'string'\n ? options.backgroundColor\n : BACKGROUND_COLOR_DEFAULT,\n backgroundPadding:\n typeof options.backgroundPadding === 'number' &&\n Number.isFinite(options.backgroundPadding) &&\n options.backgroundPadding >= 0\n ? options.backgroundPadding\n : BACKGROUND_PADDING,\n backgroundRadius:\n typeof options.backgroundRadius === 'number' &&\n Number.isFinite(options.backgroundRadius) &&\n options.backgroundRadius >= 0\n ? options.backgroundRadius\n : BACKGROUND_RADIUS,\n logoColor: typeof options.logoColor === 'string' ? options.logoColor : LOGO_COLOR_DEFAULT,\n suffix: options.suffix ? options.suffix.toString() : '0',\n logoData: typeof options.logoData === 'string' ? options.logoData : null,\n ecc: typeof options.ecc === 'number' && eccLevels[options.ecc] ? options.ecc : 3,\n incTileSize: typeof options.incTileSize === 'number' ? options.incTileSize : INC_TILE_SIZE,\n };\n\n // Code generation\n const segments = makeSegments(text);\n const qrCode = encodeSegments(segments, eccLevels[fallbackOptions.ecc], 1, 40, -1, true);\n const svgCode = convertSegmentsToSvgString(qrCode, fallbackOptions);\n\n return svgCode;\n}\n"],"names":["isFinderPattern","figure","size","x","y","pixels","width","height","right","bottom","finderRegions","FINDER_PATTERN_SIZE","rx1","ry1","rx2","ry2","extractFigures","image","visited","Array","figures","directions","isInside","cells","minX","maxX","minY","maxY","head","cx","cy","Math","dx","dy","nx","ny","figureWidth","figureHeight","cellX","cellY","figureToSvgPath","options","pixelSize","TILE_SIZE","radius","MODULE_CORNER_RADIUS","contours","buildContours","getBoundaryEdges","cornerRadius","createCornerRadiusResolver","contour","contourToRoundedPath","hasPixel","edges","px","py","left","top","hasFilledCorner","prev","current","next","getTurn","topLeft","bottomLeft","topRight","bottomRight","roundsBottomRight","edgeMap","Map","edge","key","pointKey","list","startKey","undefined","Number","start","candidates","Error","nextIndex","rightTurn","candidate","samePoint","n","commands","i","incomingLength","distance","outgoingLength","r","beforeCorner","moveTowards","afterCorner","from","to","distanceValue","length","ratio","a","b","point","INC_TILE_SIZE","convertSegmentsToSvgString","qrCode","background","getBackgroundLayout","parts","renderFinderPatterns","renderLogo","renderDefinitions","renderBackground","renderModules","getVisibleModules","isShowLogo","logoAreaSize","SMALL_QR_SIZE","logoAreaStart","row","pixel","pointPosition","scale","position","contentSize","frameWidth","contentWidth","hideQr","backgroundSize","padding","layout","QrCodeEcc","QrSegmentMode","numCharCountBits","mode","ver","encodeSegments","segs","ecl","minVersion","maxVersion","mask","boostEcl","MIN_VERSION","MAX_VERSION","version","dataUsedBits","dataCapacityBits","getNumDataCodewords","usedBits","getTotalBits","finalEcl","newEcl","bb","createBitBuffer","seg","padByte","dataCodewords","createQrCode","errorCorrectionLevel","modules","isFunction","setFunctionModule","isBlack","drawFinderPattern","dist","xx","yy","alignPatPos","getAlignmentPatternPositions","numAlign","j","drawAlignmentPattern","drawFormatBits","msk","data","rem","bits","getBit","color","allCodewords","addEccAndInterleave","getNumRawDataModules","bitIndex","vert","upward","finalMask","minPenalty","applyMask","penalty","getPenaltyScore","step","result","pos","invert","runHistory","runX","PENALTY_N1","addRunToHistory","hasFinderLikePattern","PENALTY_N3","runY","PENALTY_N2","black","total","k","PENALTY_N4","run","history","numBlocks","NUM_ERROR_CORRECTION_BLOCKS","blockEccLen","ECC_CODEWORDS_PER_BLOCK","rawCodewords","numShortBlocks","shortBlockLen","blocks","rs","createReedSolomonGenerator","dat","ecc","createQrSegment","numChars","bitData","makeBytes","makeNumeric","digits","NUMERIC_REGEX","parseInt","makeAlphanumeric","text","ALPHANUMERIC_REGEX","temp","ALPHANUMERIC_CHARSET","makeSegments","toUtf8ByteArray","ccbits","Infinity","str","encodeURI","array","val","len","degree","coefficients","root","rsMultiply","factor","coef","z","DEFAULT_SIZE","BACKGROUND_COLOR_DEFAULT","FOREGROUND_COLOR_DEFAULT","LOGO_COLOR_DEFAULT","createQR","qrSizeOrOptions","classNameLegacy","legacyOptions","TypeError","eccLevels","fallbackOptions","BACKGROUND_PADDING","BACKGROUND_RADIUS","segments","svgCode"],"mappings":"AASO,SAASA,gBAAgBC,MAAc,EAAEC,IAAY;IAC1D,MAAM,EAAEC,CAAC,EAAEC,CAAC,EAAEC,MAAM,EAAE,GAAGJ;IACzB,MAAMK,QAAQD,MAAM,CAAC,EAAE,EAAE,UAAU;IACnC,MAAME,SAASF,OAAO,MAAM;IAC5B,MAAMG,QAAQL,IAAIG,QAAQ;IAC1B,MAAMG,SAASL,IAAIG,SAAS;IAE5B,MAAMG,gBAAyD;QAC7D;YAAC;YAAG;YAAGC;YAAyBA;SAAwB;QACxD;YAACT,OAAOS;YAAqB;YAAGT,OAAO;YAAGS;SAAwB;QAClE;YAAC;YAAGT,OAAOS;YAAqBA;YAAyBT,OAAO;SAAE;KACnE;IAED,KAAK,MAAM,CAACU,KAAKC,KAAKC,KAAKC,IAAI,IAAIL,cACjC,IAAIP,KAAKS,OAAOR,KAAKS,OAAOL,SAASM,OAAOL,UAAUM,KACpD,OAAO;IAIX,OAAO;AACT;AAEO,SAASC,eAAeC,KAAkB;IAC/C,MAAMV,SAASU,MAAM,MAAM;IAC3B,MAAMX,QAAQW,KAAK,CAAC,EAAE,EAAE,UAAU;IAElC,MAAMC,UAAuBC,MAAM,IAAI,CAAC;QAAE,QAAQZ;IAAO,GAAG,IAAMY,MAAMb,OAAO,IAAI,CAAC;IAEpF,MAAMc,UAAoB,EAAE;IAE5B,MAAMC,aAAa;QACjB;YAAC;YAAG;SAAG;QACP;YAAC;YAAG;SAAE;QACN;YAAC;YAAG;SAA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,gBAAgB,IAC/BoC,OAAO,QAAQ,CAACpC,QAAQ,gBAAgB,KACxCA,QAAQ,gBAAgB,IAAI,IACxBA,QAAQ,gBAAgB,GACxB6N;QACN,WAAW,AAA6B,YAA7B,OAAO7N,QAAQ,SAAS,GAAgBA,QAAQ,SAAS,GAAGoN;QACvE,QAAQpN,QAAQ,MAAM,GAAGA,QAAQ,MAAM,CAAC,QAAQ,KAAK;QACrD,UAAU,AAA4B,YAA5B,OAAOA,QAAQ,QAAQ,GAAgBA,QAAQ,QAAQ,GAAG;QACpE,KAAK,AAAuB,YAAvB,OAAOA,QAAQ,GAAG,IAAiB0N,SAAS,CAAC1N,QAAQ,GAAG,CAAC,GAAGA,QAAQ,GAAG,GAAG;QAC/E,aAAa,AAA+B,YAA/B,OAAOA,QAAQ,WAAW,GAAgBA,QAAQ,WAAW,GAAG8D;IAC/E;IAGA,MAAMgK,WAAW7B,aAAaJ;IAC9B,MAAM7H,SAAS+B,eAAe+H,UAAUJ,SAAS,CAACC,gBAAgB,GAAG,CAAC,EAAE,GAAG,IAAI,IAAI;IACnF,MAAMI,UAAUhK,2BAA2BC,QAAQ2J;IAEnD,OAAOI;AACT"}
|
package/dist/qr.d.ts
CHANGED
|
@@ -1,79 +1,71 @@
|
|
|
1
1
|
type bit = number;
|
|
2
|
-
type byte = number;
|
|
3
2
|
type int = number;
|
|
4
|
-
export declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly
|
|
10
|
-
|
|
3
|
+
export declare const QrCodeEcc: {
|
|
4
|
+
readonly LOW: {
|
|
5
|
+
readonly ordinal: 0;
|
|
6
|
+
readonly formatBits: 1;
|
|
7
|
+
};
|
|
8
|
+
readonly MEDIUM: {
|
|
9
|
+
readonly ordinal: 1;
|
|
10
|
+
readonly formatBits: 0;
|
|
11
|
+
};
|
|
12
|
+
readonly QUARTILE: {
|
|
13
|
+
readonly ordinal: 2;
|
|
14
|
+
readonly formatBits: 3;
|
|
15
|
+
};
|
|
16
|
+
readonly HIGH: {
|
|
17
|
+
readonly ordinal: 3;
|
|
18
|
+
readonly formatBits: 2;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type QrCodeEccValue = (typeof QrCodeEcc)[keyof typeof QrCodeEcc];
|
|
22
|
+
export declare const QrSegmentMode: {
|
|
23
|
+
readonly NUMERIC: {
|
|
24
|
+
readonly modeBits: 1;
|
|
25
|
+
readonly numBitsCharCount: readonly [10, 12, 14];
|
|
26
|
+
};
|
|
27
|
+
readonly ALPHANUMERIC: {
|
|
28
|
+
readonly modeBits: 2;
|
|
29
|
+
readonly numBitsCharCount: readonly [9, 11, 13];
|
|
30
|
+
};
|
|
31
|
+
readonly BYTE: {
|
|
32
|
+
readonly modeBits: 4;
|
|
33
|
+
readonly numBitsCharCount: readonly [8, 16, 16];
|
|
34
|
+
};
|
|
35
|
+
readonly KANJI: {
|
|
36
|
+
readonly modeBits: 8;
|
|
37
|
+
readonly numBitsCharCount: readonly [8, 10, 12];
|
|
38
|
+
};
|
|
39
|
+
readonly ECI: {
|
|
40
|
+
readonly modeBits: 7;
|
|
41
|
+
readonly numBitsCharCount: readonly [0, 0, 0];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type QrSegmentModeValue = (typeof QrSegmentMode)[keyof typeof QrSegmentMode];
|
|
45
|
+
export interface QrCode {
|
|
46
|
+
/** The version number of this QR Code, between 1 and 40 (inclusive). */
|
|
11
47
|
readonly version: int;
|
|
12
|
-
|
|
48
|
+
/** The error correction level used in this QR Code. */
|
|
49
|
+
readonly errorCorrectionLevel: QrCodeEccValue;
|
|
50
|
+
/** The width and height of this QR Code, measured in modules, between 21 and 177 (inclusive). */
|
|
51
|
+
readonly size: int;
|
|
52
|
+
/** The index of the mask pattern used in this QR Code, between 0 and 7 (inclusive). */
|
|
13
53
|
readonly mask: int;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
toSvgString(border: int): string;
|
|
17
|
-
private drawFunctionPatterns;
|
|
18
|
-
private drawFormatBits;
|
|
19
|
-
private drawVersion;
|
|
20
|
-
private drawFinderPattern;
|
|
21
|
-
private drawAlignmentPattern;
|
|
22
|
-
private setFunctionModule;
|
|
23
|
-
private addEccAndInterleave;
|
|
24
|
-
private drawCodewords;
|
|
25
|
-
private applyMask;
|
|
26
|
-
private getPenaltyScore;
|
|
27
|
-
private getAlignmentPatternPositions;
|
|
28
|
-
private static getNumRawDataModules;
|
|
29
|
-
private static getNumDataCodewords;
|
|
30
|
-
private static addRunToHistory;
|
|
31
|
-
private static hasFinderLikePattern;
|
|
32
|
-
static readonly MIN_VERSION: int;
|
|
33
|
-
static readonly MAX_VERSION: int;
|
|
34
|
-
private static readonly PENALTY_N1;
|
|
35
|
-
private static readonly PENALTY_N2;
|
|
36
|
-
private static readonly PENALTY_N3;
|
|
37
|
-
private static readonly PENALTY_N4;
|
|
38
|
-
private static readonly ECC_CODEWORDS_PER_BLOCK;
|
|
39
|
-
private static readonly NUM_ERROR_CORRECTION_BLOCKS;
|
|
54
|
+
/** The modules of this QR Code (false = white, true = black). */
|
|
55
|
+
readonly modules: boolean[][];
|
|
40
56
|
}
|
|
41
|
-
export declare
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
export declare function encodeSegments(segs: QrSegment[], ecl: QrCodeEccValue, minVersion?: int, maxVersion?: int, mask?: int, boostEcl?: boolean): QrCode;
|
|
58
|
+
export interface QrSegment {
|
|
59
|
+
/** The mode indicator of this segment. */
|
|
60
|
+
readonly mode: QrSegmentModeValue;
|
|
61
|
+
/** The length of this segment's unencoded data. Measured in characters for
|
|
62
|
+
* numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.
|
|
63
|
+
* Always zero or positive. Not the same as the data's bit length.
|
|
64
|
+
*/
|
|
48
65
|
readonly numChars: int;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
getData(): Array<bit>;
|
|
52
|
-
static getTotalBits(segs: Array<QrSegment>, version: int): number;
|
|
53
|
-
private static toUtf8ByteArray;
|
|
54
|
-
static readonly NUMERIC_REGEX: RegExp;
|
|
55
|
-
static readonly ALPHANUMERIC_REGEX: RegExp;
|
|
56
|
-
private static readonly ALPHANUMERIC_CHARSET;
|
|
57
|
-
}
|
|
58
|
-
export declare class QrCodeEcc {
|
|
59
|
-
static readonly LOW: QrCodeEcc;
|
|
60
|
-
static readonly MEDIUM: QrCodeEcc;
|
|
61
|
-
static readonly QUARTILE: QrCodeEcc;
|
|
62
|
-
static readonly HIGH: QrCodeEcc;
|
|
63
|
-
readonly ordinal: int;
|
|
64
|
-
readonly formatBits: int;
|
|
65
|
-
private constructor();
|
|
66
|
-
}
|
|
67
|
-
export declare class QrSegmentMode {
|
|
68
|
-
static readonly NUMERIC: QrSegmentMode;
|
|
69
|
-
static readonly ALPHANUMERIC: QrSegmentMode;
|
|
70
|
-
static readonly BYTE: QrSegmentMode;
|
|
71
|
-
static readonly KANJI: QrSegmentMode;
|
|
72
|
-
static readonly ECI: QrSegmentMode;
|
|
73
|
-
readonly modeBits: int;
|
|
74
|
-
private readonly numBitsCharCount;
|
|
75
|
-
private constructor();
|
|
76
|
-
numCharCountBits(ver: int): int;
|
|
66
|
+
/** Returns a new copy of the data bits of this segment. */
|
|
67
|
+
getData(): bit[];
|
|
77
68
|
}
|
|
69
|
+
export declare function makeSegments(text: string): QrSegment[];
|
|
78
70
|
export {};
|
|
79
71
|
//# sourceMappingURL=qr.d.ts.map
|