@vkontakte/vk-qr 2.1.1 → 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.
@@ -0,0 +1 @@
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,MAA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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 ADDED
@@ -0,0 +1,71 @@
1
+ type bit = number;
2
+ type int = number;
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). */
47
+ readonly version: int;
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). */
53
+ readonly mask: int;
54
+ /** The modules of this QR Code (false = white, true = black). */
55
+ readonly modules: boolean[][];
56
+ }
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
+ */
65
+ readonly numChars: int;
66
+ /** Returns a new copy of the data bits of this segment. */
67
+ getData(): bit[];
68
+ }
69
+ export declare function makeSegments(text: string): QrSegment[];
70
+ export {};
71
+ //# sourceMappingURL=qr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr.d.ts","sourceRoot":"","sources":["../src/qr.ts"],"names":[],"mappings":"AAuBA,KAAK,GAAG,GAAG,MAAM,CAAC;AAElB,KAAK,GAAG,GAAG,MAAM,CAAC;AAOlB,eAAO,MAAM,SAAS;aACpB,GAAG;iBAAI,OAAO,EAAE,CAAC;iBAAE,UAAU,EAAE,CAAC;;aAChC,MAAM;iBAAI,OAAO,EAAE,CAAC;iBAAE,UAAU,EAAE,CAAC;;aACnC,QAAQ;iBAAI,OAAO,EAAE,CAAC;iBAAE,UAAU,EAAE,CAAC;;aACrC,IAAI;iBAAI,OAAO,EAAE,CAAC;iBAAE,UAAU,EAAE,CAAC;;CACzB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAKxE,eAAO,MAAM,aAAa;aACxB,OAAO;iBAAI,QAAQ,EAAE,CAAG;iBAAE,gBAAgB,YAA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AClB;AA2DD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAMtD"}
@@ -0,0 +1,8 @@
1
+ import type { Figure } from './figures.js';
2
+ interface SvgPathOptions {
3
+ pixelSize?: number;
4
+ radius?: number;
5
+ }
6
+ export declare function figureToSvgPath(figure: Figure, options?: SvgPathOptions): string;
7
+ export {};
8
+ //# sourceMappingURL=svg-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg-path.d.ts","sourceRoot":"","sources":["../src/svg-path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,UAAU,cAAc;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAcD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,MAAM,CAOpF"}
package/dist/svg.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { QrCode } from './qr.js';
2
+ import type { RequiredQrOptions } from './types.js';
3
+ export declare const INC_TILE_SIZE = 100;
4
+ /** Converts a QR module matrix to SVG. */
5
+ export declare function convertSegmentsToSvgString(qrCode: QrCode, options: RequiredQrOptions): string;
6
+ //# sourceMappingURL=svg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAUpD,eAAO,MAAM,aAAa,MAAY,CAAC;AASvC,0CAA0C;AAC1C,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAiC7F"}
@@ -0,0 +1,69 @@
1
+ export type QrOptions = {
2
+ /**
3
+ * Size of QR code
4
+ * @default 128
5
+ */
6
+ qrSize?: number | undefined;
7
+ /**
8
+ * Class name of root SVG element
9
+ */
10
+ className?: string | undefined;
11
+ /**
12
+ * Show VK logo in center of QR code
13
+ * @default false
14
+ */
15
+ isShowLogo?: boolean | undefined;
16
+ /**
17
+ * Show QR background
18
+ * @default false
19
+ */
20
+ isShowBackground?: boolean | undefined;
21
+ /**
22
+ * QR code background HEX color. Works if `isShowBackground` is enabled.
23
+ * @default "#ffffff"
24
+ */
25
+ backgroundColor?: string | undefined;
26
+ /**
27
+ * Background frame thickness in output pixels. Works if `isShowBackground` is enabled.
28
+ * Must be finite and non-negative. Clamped to half of `qrSize`.
29
+ * @default 20
30
+ */
31
+ backgroundPadding?: number | undefined;
32
+ /**
33
+ * Background corner radius in output pixels. Works if `isShowBackground` is enabled.
34
+ * Must be finite and non-negative. Clamped to half of `qrSize`.
35
+ * @default 36
36
+ */
37
+ backgroundRadius?: number | undefined;
38
+ /**
39
+ * QR code HEX color
40
+ */
41
+ foregroundColor?: string | undefined;
42
+ /**
43
+ * Color of logo
44
+ * @default "#000000"
45
+ */
46
+ logoColor?: string | undefined;
47
+ /**
48
+ * Reference to logo as a reference IRI
49
+ */
50
+ logoData?: string | null | undefined;
51
+ /**
52
+ * SVG elements id postfix
53
+ */
54
+ suffix?: string | undefined;
55
+ /**
56
+ * ECC Level
57
+ */
58
+ ecc?: number | undefined;
59
+ /**
60
+ * @deprecated Ignored. QR module size is fixed internally.
61
+ */
62
+ incTileSize?: number | undefined;
63
+ };
64
+ type NotUndefined<T> = {
65
+ [k in keyof T]-?: Exclude<T[k], undefined>;
66
+ };
67
+ export type RequiredQrOptions = NotUndefined<QrOptions>;
68
+ export {};
69
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEvC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAErC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEtC;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAErC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAErC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,KAAK,YAAY,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;CAAE,CAAC;AAEtE,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,82 +1,57 @@
1
1
  {
2
- "name": "@vkontakte/vk-qr",
3
- "version": "2.1.1",
4
- "description": "QR Code generator",
5
- "main": "dist/cjs/index.js",
6
- "browser": "dist/umd/qrCodeGenerator.js",
7
- "module": "dist/es/index.js",
8
- "jsxnext:main": "dist/es/index.js",
9
- "umdName": "qrCodeGenerator",
10
- "types": "dist/types/index.d.ts",
11
- "files": [
12
- "dist",
13
- "src"
14
- ],
15
- "scripts": {
16
- "test": "jest",
17
- "watch": "rollup -c -w",
18
- "build": "rimraf dist && NODE_ENV=production rollup -c",
19
- "build:types": "rimraf dist/types && tsc src/index.ts",
20
- "lint": "eslint src/*.ts",
21
- "size": "size-limit",
22
- "prepublish": "yarn build"
23
- },
24
- "keywords": [],
25
- "author": "VK.com",
26
- "license": "MIT",
27
- "repository": "VKCOM/vk-qr",
28
- "jest": {
29
- "testMatch": [
30
- "<rootDir>/tests/**/*.js"
31
- ]
32
- },
33
- "devDependencies": {
34
- "@babel/cli": "^7.5.0",
35
- "@babel/core": "^7.5.4",
36
- "@babel/preset-env": "^7.5.5",
37
- "@babel/preset-typescript": "^7.3.3",
38
- "@size-limit/preset-small-lib": "^11.0.0",
39
- "@types/jest": "^24.0.15",
40
- "@types/prettier": "^1.16.4",
41
- "@typescript-eslint/eslint-plugin": "^2.0.0",
42
- "@typescript-eslint/parser": "^2.0.0",
43
- "babel-plugin-add-module-exports": "^0.2.1",
44
- "convert-svg-to-png": "^0.6.4",
45
- "cross-env": "^5.2.0",
46
- "eslint": "^6.0.1",
47
- "eslint-plugin-babel": "^4.1.2",
48
- "eslint-plugin-import": "^2.18.0",
49
- "eslint-plugin-prettier": "^3.1.0",
50
- "fast-xml-parser": "^3.12.17",
51
- "jest": "^24.9.0",
52
- "jest-image-snapshot": "^2.9.0",
53
- "js-beautify": "^1.10.0",
54
- "prettier": "^1.18.2",
55
- "rimraf": "^2.6.1",
56
- "rollup": "^1.16.7",
57
- "rollup-plugin-babel": "^4.3.3",
58
- "rollup-plugin-bundle-size": "^1.0.3",
59
- "rollup-plugin-commonjs": "^10.0.1",
60
- "rollup-plugin-node-resolve": "^5.2.0",
61
- "rollup-plugin-typescript2": "^0.22.0",
62
- "rollup-plugin-uglify": "^6.0.2",
63
- "size-limit": "^11.0.0",
64
- "ts-node": "^8.3.0",
65
- "typescript": "^3.5.3",
66
- "xml-js": "^1.6.11"
67
- },
68
- "size-limit": [
69
- {
70
- "path": "dist/cjs/index.js"
71
- },
72
- {
73
- "path": "dist/es/index.js"
74
- },
75
- {
76
- "path": "dist/umd/qrCodeGenerator.js"
77
- }
78
- ],
79
- "publishConfig": {
80
- "access": "public"
81
- }
2
+ "name": "@vkontakte/vk-qr",
3
+ "version": "3.1.0",
4
+ "description": "QR Code generator",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "main": "dist/index.js",
15
+ "module": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "files": [
18
+ "dist",
19
+ "src"
20
+ ],
21
+ "scripts": {
22
+ "test": "node --test tests/**/*.test.ts",
23
+ "test:update": "UPDATE_SNAPSHOTS=1 node --test tests/**/*.test.ts",
24
+ "watch": "rslib --watch",
25
+ "build": "rslib",
26
+ "lint": "yarn lint:biome && yarn lint:types",
27
+ "size": "size-limit",
28
+ "lint:biome": "biome check",
29
+ "lint:biome:fix": "biome check --write",
30
+ "lint:types": "tsc -b",
31
+ "prepack": "yarn build"
32
+ },
33
+ "keywords": [],
34
+ "author": "vk.ru",
35
+ "license": "MIT",
36
+ "repository": "VKCOM/vk-qr",
37
+ "dependencies": {
38
+ "@swc/helpers": "^0.5.21"
39
+ },
40
+ "devDependencies": {
41
+ "@biomejs/biome": "^2.4.12",
42
+ "@rslib/core": "^1.0.2",
43
+ "@size-limit/preset-small-lib": "^14.0.0",
44
+ "@types/node": "^26.0.0",
45
+ "size-limit": "^14.0.0",
46
+ "typescript": "^7.0.2"
47
+ },
48
+ "size-limit": [
49
+ {
50
+ "path": "dist/index.js"
51
+ }
52
+ ],
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
82
57
  }
@@ -0,0 +1,9 @@
1
+ /** SVG units per QR module. */
2
+ export const TILE_SIZE = 100;
3
+ export const FINDER_PATTERN_SIZE = 7;
4
+ export const SMALL_QR_SIZE = 25;
5
+ export const MODULE_CORNER_RADIUS = 35;
6
+ export const FINDER_CORNER_RADIUS = 67;
7
+ /** Default background dimensions in output pixels. */
8
+ export const BACKGROUND_PADDING = 20;
9
+ export const BACKGROUND_RADIUS = 36;