@vielzeug/sigil 26.10.0 → 26.10.1
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 +5 -5
- package/dist/_galois.cjs.map +1 -1
- package/dist/_galois.d.ts +1 -1
- package/dist/_galois.d.ts.map +1 -1
- package/dist/_galois.js.map +1 -1
- package/dist/_matrix.cjs.map +1 -1
- package/dist/_matrix.d.ts +1 -1
- package/dist/_matrix.d.ts.map +1 -1
- package/dist/_matrix.js.map +1 -1
- package/dist/_segments.cjs.map +1 -1
- package/dist/_segments.d.ts +1 -1
- package/dist/_segments.d.ts.map +1 -1
- package/dist/_segments.js.map +1 -1
- package/dist/_tables.cjs.map +1 -1
- package/dist/_tables.d.ts +4 -4
- package/dist/_tables.js.map +1 -1
- package/dist/canvas.cjs.map +1 -1
- package/dist/canvas.d.ts +1 -1
- package/dist/canvas.js.map +1 -1
- package/dist/encode.cjs.map +1 -1
- package/dist/encode.d.ts +2 -2
- package/dist/encode.js.map +1 -1
- package/dist/scan.cjs.map +1 -1
- package/dist/scan.js.map +1 -1
- package/dist/sigil.cjs.map +1 -1
- package/dist/sigil.iife.js.map +1 -1
- package/dist/sigil.js.map +1 -1
- package/dist/svg.cjs.map +1 -1
- package/dist/svg.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/sigil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sigil.js","names":[],"sources":["../src/errors.ts","../src/canvas.ts","../src/_tables.ts","../src/_format.ts","../src/_mask.ts","../src/_matrix.ts","../src/_galois.ts","../src/_reed-solomon.ts","../src/_segments.ts","../src/encode.ts","../src/scan.ts","../src/svg.ts"],"sourcesContent":["/**\n * Base class for all sigil errors.\n * Use `instanceof SigilError` to catch any sigil-originated error in one branch.\n */\nexport class SigilError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when input data does not fit in the requested version/level. */\nexport class SigilCapacityError extends SigilError {\n readonly bytes: number;\n readonly maxBytes: number;\n readonly version: number;\n\n constructor(message: string, bytes: number, maxBytes: number, version: number, opts?: ErrorOptions) {\n super(message, opts);\n this.bytes = bytes;\n this.maxBytes = maxBytes;\n this.version = version;\n }\n}\n\n/** Thrown for an invalid option: version/minVersion out of range, mask outside 0–7. */\nexport class SigilOptionError extends SigilError {}\n\n/**\n * Thrown when the environment lacks `BarcodeDetector`, `getUserMedia`, or QR\n * format support. Feature-detect with `isQrScanSupported()`/`qrScanSupport()`.\n */\nexport class SigilUnsupportedError extends SigilError {}\n\n/** Thrown when camera access is denied (wraps `NotAllowedError`). */\nexport class SigilPermissionError extends SigilError {}\n\n/** Thrown when a disposed scanner is used. */\nexport class SigilDisposedError extends SigilError {}\n","import { SigilUnsupportedError } from './errors';\nimport type { QrCanvasOptions, QrMatrix } from './types';\n\n/**\n * Canvas rendering — the only DOM-touching output path.\n * Resizes the canvas to `(size + 2*margin) * scale` CSS pixels, backing-store\n * scaled by `devicePixelRatio`, and paints one `fillRect` per dark module.\n * Returns the CSS pixel size so callers can size wrappers.\n */\nexport function drawToCanvas(matrix: QrMatrix, canvas: HTMLCanvasElement, options: QrCanvasOptions = {}): number {\n const margin = options.margin ?? 4;\n const scale = options.scale ?? 1;\n const dark = options.dark ?? '#000000';\n const light = options.light ?? '#ffffff';\n const cssSize = (matrix.size + margin * 2) * scale;\n const dpr = globalThis.devicePixelRatio || 1;\n\n canvas.width = cssSize * dpr;\n canvas.height = cssSize * dpr;\n canvas.style.width = `${cssSize}px`;\n canvas.style.height = `${cssSize}px`;\n\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new SigilUnsupportedError('Canvas 2D context unavailable');\n ctx.scale(dpr, dpr);\n ctx.fillStyle = light;\n ctx.fillRect(0, 0, cssSize, cssSize);\n ctx.fillStyle = dark;\n for (let y = 0; y < matrix.size; y++)\n for (let x = 0; x < matrix.size; x++)\n if (matrix.get(x, y)) ctx.fillRect((x + margin) * scale, (y + margin) * scale, scale, scale);\n return cssSize;\n}\n","import type { QrErrorCorrection, QrMode } from './types';\n\n/**\n * QR Model 2 lookup tables, transcribed from ISO/IEC 18004:2015:\n * - `EC_CODEWORDS_PER_BLOCK` / `NUM_EC_BLOCKS` — Table 9 (error-correction\n * characteristics). Stored as per-block EC codewords and block count; the\n * group-1/group-2 split is derived, since all blocks share one EC length.\n * - `alignmentPatternPositions` — Table E.1, computed by the spec formula.\n * - `CHAR_COUNT_BITS` — Table 3 (character-count indicator bit widths).\n * - `FORMAT_EC_BITS` — Table 10 (2-bit level field inside format information).\n *\n * `tables.test.ts` cross-checks every entry against the raw-module formula, so\n * a transcription slip fails the consistency test before the decode oracle runs.\n */\n\n/** Index order used by the table rows below. */\nexport const EC_LEVELS = ['L', 'M', 'Q', 'H'] as const;\n\nexport const ALPHANUMERIC_CHARSET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';\n\n/** Mode indicators (Table 2). */\nexport const MODE_BITS: Record<QrMode, number> = {\n alphanumeric: 0b0010,\n byte: 0b0100,\n numeric: 0b0001,\n};\n\n/** Character-count indicator widths for version groups 1–9 / 10–26 / 27–40. */\nexport const CHAR_COUNT_BITS: Record<QrMode, readonly [number, number, number]> = {\n alphanumeric: [9, 11, 13],\n byte: [8, 16, 16],\n numeric: [10, 12, 14],\n};\n\n/** EC level bits inside format information (L=01, M=00, Q=11, H=10). */\nexport const FORMAT_EC_BITS: Record<QrErrorCorrection, number> = { H: 0b10, L: 0b01, M: 0b00, Q: 0b11 };\n\n/** Row 0 = L, row 1 = M, row 2 = Q, row 3 = H; column 0 unused (versions start at 1). */\nexport const EC_CODEWORDS_PER_BLOCK: ReadonlyArray<ReadonlyArray<number>> = [\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, 30, 26, 28, 30, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\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, 28, 28, 28, 28, 28, 28,\n 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ],\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, 30, 30, 30, 28, 30, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\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, 30, 30, 30, 30, 30, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n];\n\nexport const NUM_EC_BLOCKS: ReadonlyArray<ReadonlyArray<number>> = [\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, 14, 15, 16, 17, 18, 19,\n 19, 20, 21, 22, 24, 25,\n ],\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, 25, 26, 28, 29, 31,\n 33, 35, 37, 38, 40, 43, 45, 47, 49,\n ],\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, 34, 34, 35, 38, 40, 43,\n 45, 48, 51, 53, 56, 59, 62, 65, 68,\n ],\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, 37, 40, 42, 45, 48,\n 51, 56, 59, 62, 65, 68, 71, 74, 77, 81,\n ],\n];\n\nconst ecIndex = (level: QrErrorCorrection): number => EC_LEVELS.indexOf(level);\n\n/** Total modules per side. */\nexport const matrixSize = (version: number): number => version * 4 + 17;\n\n/** Alignment-pattern center coordinates (Table E.1 formula). */\nexport function alignmentPatternPositions(version: number): readonly number[] {\n if (version === 1) return [];\n const numAlign = Math.floor(version / 7) + 2;\n const step = version === 32 ? 26 : Math.ceil((version * 4 + 4) / (numAlign * 2 - 2)) * 2;\n const result = [6];\n for (let pos = version * 4 + 10; result.length < numAlign; pos -= step) result.splice(1, 0, pos);\n return result;\n}\n\n/**\n * Total raw modules available for data + EC + remainder bits, derived from the\n * symbol geometry (Table 1 / Annex A): full grid minus finders, separators,\n * timing, alignment, dark module, format and version information.\n */\nexport function rawDataModules(version: number): number {\n let result = (16 * version + 128) * version + 64;\n if (version >= 2) {\n const numAlign = Math.floor(version / 7) + 2;\n result -= (25 * numAlign - 10) * numAlign - 55;\n if (version >= 7) result -= 36;\n }\n return result;\n}\n\n/** Total codewords (data + EC) for a version. */\nexport const totalCodewords = (version: number): number => Math.floor(rawDataModules(version) / 8);\n\n/** Leftover bits after the codeword stream (0, 3, 4, or 7 by version). */\nexport const remainderBits = (version: number): number => rawDataModules(version) % 8;\n\nexport function ecCodewordsPerBlock(version: number, level: QrErrorCorrection): number {\n return EC_CODEWORDS_PER_BLOCK[ecIndex(level)][version];\n}\n\nexport function numEcBlocks(version: number, level: QrErrorCorrection): number {\n return NUM_EC_BLOCKS[ecIndex(level)][version];\n}\n\n/** Data codewords for a (version, level) pair. */\nexport function dataCodewords(version: number, level: QrErrorCorrection): number {\n return totalCodewords(version) - ecCodewordsPerBlock(version, level) * numEcBlocks(version, level);\n}\n\n/** Version group for the character-count indicator: 0 → 1–9, 1 → 10–26, 2 → 27–40. */\nexport function versionGroup(version: number): 0 | 1 | 2 {\n return version <= 9 ? 0 : version <= 26 ? 1 : 2;\n}\n","import type { QrGrid } from './_matrix';\nimport { FORMAT_EC_BITS } from './_tables';\nimport type { QrErrorCorrection } from './types';\n\n/**\n * Format and version information (§7.9, Annexes C–D):\n * - Format: 5 data bits (2 EC + 3 mask) → BCH(15,5) remainder → XOR 0x5412,\n * written twice around the finders.\n * - Version (v≥7): 6 data bits → BCH(18,6) remainder, written twice in the\n * 6×3 blocks at top-right and bottom-left.\n */\n\nconst BCH_FORMAT_POLY = 0b10100110111; // x¹⁰+x⁸+x⁵+x⁴+x²+x+1\nconst BCH_FORMAT_MASK = 0b101010000010010; // 0x5412\nconst BCH_VERSION_POLY = 0b1111100100101; // x¹²+x¹¹+x¹⁰+x⁹+x⁸+x⁵+x²+1\n\n/** 15-bit format information word for (level, mask). */\nexport function formatInfoBits(level: QrErrorCorrection, mask: number): number {\n const data = (FORMAT_EC_BITS[level] << 3) | mask;\n let rem = data;\n for (let i = 0; i < 10; i++) rem = (rem << 1) ^ (((rem >>> 9) & 1) * BCH_FORMAT_POLY);\n return ((data << 10) | (rem & 0x3ff)) ^ BCH_FORMAT_MASK;\n}\n\n/** 18-bit version information word (version ≥ 7). */\nexport function versionInfoBits(version: number): number {\n let rem = version;\n for (let i = 0; i < 12; i++) rem = (rem << 1) ^ (((rem >>> 11) & 1) * BCH_VERSION_POLY);\n return (version << 12) | (rem & 0xfff);\n}\n\nconst setFunction = (grid: QrGrid, x: number, y: number, dark: boolean): void => {\n grid.modules[y][x] = dark;\n grid.isFunction[y][x] = true;\n};\n\n/** Write both copies of the 15-bit format word plus the dark module. */\nexport function drawFormatInfo(grid: QrGrid, level: QrErrorCorrection, mask: number): void {\n const size = grid.size;\n const bits = formatInfoBits(level, mask);\n const bit = (i: number) => ((bits >>> i) & 1) === 1;\n\n // First copy around the top-left finder.\n for (let i = 0; i <= 5; i++) setFunction(grid, 8, i, bit(i));\n setFunction(grid, 8, 7, bit(6));\n setFunction(grid, 8, 8, bit(7));\n setFunction(grid, 7, 8, bit(8));\n for (let i = 9; i < 15; i++) setFunction(grid, 14 - i, 8, bit(i));\n\n // Second copy: row 8 beside the top-right finder (bits 0–7),\n // column 8 beside the bottom-left finder (bits 8–14).\n for (let i = 0; i < 8; i++) setFunction(grid, size - 1 - i, 8, bit(i));\n for (let i = 8; i < 15; i++) setFunction(grid, 8, size - 15 + i, bit(i));\n\n // Always-dark module below the bottom-left strip.\n setFunction(grid, 8, size - 8, true);\n}\n\n/** Write both 6×3 version-information blocks (v≥7). */\nexport function drawVersionInfo(grid: QrGrid, version: number): void {\n if (version < 7) return;\n const size = grid.size;\n const bits = versionInfoBits(version);\n for (let i = 0; i < 18; i++) {\n const dark = ((bits >>> i) & 1) === 1;\n const a = size - 11 + (i % 3);\n const b = Math.floor(i / 3);\n setFunction(grid, a, b, dark); // top-right\n setFunction(grid, b, a, dark); // bottom-left\n }\n}\n","import type { QrGrid } from './_matrix';\n\n/**\n * Data masks and penalty scoring (§7.8.2–7.8.3):\n * eight mask functions XORed onto data modules only, then four penalty rules\n * (N1=3 runs, N2=3 blocks, N3=40 finder-like patterns, N4=10 dark ratio).\n */\n\ntype MaskFn = (x: number, y: number) => boolean;\n\nexport const MASK_FNS: readonly MaskFn[] = [\n (x, y) => (x + y) % 2 === 0,\n (_x, y) => y % 2 === 0,\n (x) => x % 3 === 0,\n (x, y) => (x + y) % 3 === 0,\n (x, y) => (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0,\n (x, y) => ((x * y) % 2) + ((x * y) % 3) === 0,\n (x, y) => (((x * y) % 2) + ((x * y) % 3)) % 2 === 0,\n (x, y) => (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,\n];\n\n/** XOR mask `m` onto every non-function module. Idempotent per mask. */\nexport function applyMask(grid: QrGrid, mask: number): void {\n const fn = MASK_FNS[mask];\n for (let y = 0; y < grid.size; y++)\n for (let x = 0; x < grid.size; x++)\n if (!grid.isFunction[y][x] && fn(x, y)) grid.modules[y][x] = !grid.modules[y][x];\n}\n\nconst PENALTY_N1 = 3;\nconst PENALTY_N2 = 3;\nconst PENALTY_N3 = 40;\nconst PENALTY_N4 = 10;\n\n// Runs of ≥5 same-color modules in a row or column: N1 + (run − 5).\nfunction penaltyRuns(grid: QrGrid): number {\n let penalty = 0;\n const line = (same: boolean, run: number): number => {\n if (!same && run >= 5) penalty += PENALTY_N1 + run - 5;\n return same ? run + 1 : 1;\n };\n for (let i = 0; i < grid.size; i++) {\n let runRow = 1;\n let runCol = 1;\n for (let j = 1; j < grid.size; j++) {\n runRow = line(grid.modules[i][j] === grid.modules[i][j - 1], runRow);\n runCol = line(grid.modules[j][i] === grid.modules[j - 1][i], runCol);\n }\n if (runRow >= 5) penalty += PENALTY_N1 + runRow - 5;\n if (runCol >= 5) penalty += PENALTY_N1 + runCol - 5;\n }\n return penalty;\n}\n\n// 2×2 blocks of a single color.\nfunction penaltyBlocks(grid: QrGrid): number {\n let penalty = 0;\n for (let y = 0; y < grid.size - 1; y++)\n for (let x = 0; x < grid.size - 1; x++) {\n const c = grid.modules[y][x];\n if (c === grid.modules[y][x + 1] && c === grid.modules[y + 1][x] && c === grid.modules[y + 1][x + 1])\n penalty += PENALTY_N2;\n }\n return penalty;\n}\n\n// 1:1:3:1:1 finder-like patterns with a 4-module light border on either side.\nfunction penaltyFinderLike(grid: QrGrid): number {\n const size = grid.size;\n let penalty = 0;\n const checkLine = (get: (i: number) => boolean): void => {\n for (let i = 0; i + 11 <= size; i++) {\n const window = Array.from({ length: 11 }, (_, k) => get(i + k));\n const coreA = [false, false, false, false, true, false, true, true, true, false, true];\n const coreB = [true, false, true, true, true, false, true, false, false, false, false];\n if (window.every((v, k) => v === coreA[k]) || window.every((v, k) => v === coreB[k])) penalty += PENALTY_N3;\n }\n };\n for (let y = 0; y < size; y++) checkLine((i) => grid.modules[y][i]);\n for (let x = 0; x < size; x++) checkLine((i) => grid.modules[i][x]);\n return penalty;\n}\n\n// Ratio of dark modules: each 5% step away from 50% costs N4.\nfunction penaltyRatio(grid: QrGrid): number {\n let dark = 0;\n for (const row of grid.modules) for (const m of row) if (m) dark++;\n const total = grid.size * grid.size;\n const k = Math.floor(Math.abs(dark * 20 - total * 10) / total);\n return k * PENALTY_N4;\n}\n\n/** Total penalty score for a fully masked matrix. */\nexport function penaltyScore(grid: QrGrid): number {\n return penaltyRuns(grid) + penaltyBlocks(grid) + penaltyFinderLike(grid) + penaltyRatio(grid);\n}\n","import { alignmentPatternPositions } from './_tables';\n\n/**\n * Module placement (§7.7–7.9, Annex E): function patterns are drawn first and\n * recorded in `isFunction`, then the codeword bit stream fills the remaining\n * modules in a two-column zigzag starting bottom-right, skipping column 6.\n */\n\nexport interface QrGrid {\n /** Modules owned by function patterns — skipped by data placement and masks. */\n readonly isFunction: boolean[][];\n /** Final module colors; `true` = dark. Mutable during construction. */\n modules: boolean[][];\n readonly size: number;\n}\n\nexport function createGrid(size: number): QrGrid {\n return {\n isFunction: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n modules: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n size,\n };\n}\n\nconst setFunction = (grid: QrGrid, x: number, y: number, dark: boolean): void => {\n grid.modules[y][x] = dark;\n grid.isFunction[y][x] = true;\n};\n\n/** 7×7 finder pattern plus the one-module separator ring, centered at (x+3, y+3). */\nfunction drawFinder(grid: QrGrid, x: number, y: number): void {\n for (let dy = -4; dy <= 4; dy++)\n for (let dx = -4; dx <= 4; dx++) {\n const xx = x + 3 + dx;\n const yy = y + 3 + dy;\n if (xx < 0 || yy < 0 || xx >= grid.size || yy >= grid.size) continue;\n const dist = Math.max(Math.abs(dx), Math.abs(dy));\n setFunction(grid, xx, yy, dist !== 2 && dist !== 4);\n }\n}\n\n/** Alternating timing pattern along row/col 6, between the finders. */\nfunction drawTiming(grid: QrGrid): void {\n for (let i = 8; i < grid.size - 8; i++) {\n const dark = i % 2 === 0;\n if (!grid.isFunction[6][i]) setFunction(grid, i, 6, dark);\n if (!grid.isFunction[i][6]) setFunction(grid, 6, i, dark);\n }\n}\n\n/** 5×5 alignment pattern centered at (cx, cy). */\nfunction drawAlignment(grid: QrGrid, cx: number, cy: number): void {\n for (let dy = -2; dy <= 2; dy++)\n for (let dx = -2; dx <= 2; dx++) setFunction(grid, cx + dx, cy + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n}\n\n/**\n * Reserve the 15 format-info modules around each finder (both copies) and the\n * 6×3 version-info blocks for v≥7 — drawn later by `_format.ts`, but data\n * placement must skip them now.\n */\nfunction reserveFormatAreas(grid: QrGrid): void {\n const size = grid.size;\n // Around the top-left finder.\n for (let i = 0; i <= 8; i++) {\n if (i !== 6) {\n grid.isFunction[8][i] = true;\n grid.isFunction[i][8] = true;\n }\n }\n // Second copy: column 8 rows size-1..size-7 beside the bottom-left finder,\n // row 8 columns size-1..size-8 beside the top-right finder.\n for (let i = 0; i < 7; i++) grid.isFunction[size - 1 - i][8] = true;\n for (let i = 0; i < 8; i++) grid.isFunction[8][size - 1 - i] = true;\n // Always-dark module below the bottom-left format strip.\n grid.isFunction[size - 8][8] = true;\n}\n\nfunction reserveVersionAreas(grid: QrGrid, version: number): void {\n if (version < 7) return;\n const size = grid.size;\n for (let i = 0; i < 18; i++) {\n const a = size - 11 + (i % 3);\n const b = Math.floor(i / 3);\n grid.isFunction[b][a] = true; // top-right block\n grid.isFunction[a][b] = true; // bottom-left block\n }\n}\n\n/** Draw every function pattern and mark reserved areas. */\nexport function drawFunctionPatterns(grid: QrGrid, version: number): void {\n drawFinder(grid, 0, 0);\n drawFinder(grid, grid.size - 7, 0);\n drawFinder(grid, 0, grid.size - 7);\n drawTiming(grid);\n const positions = alignmentPatternPositions(version);\n for (const cy of positions)\n for (const cx of positions) {\n // Skip the three corners covered by finder patterns.\n const isCorner =\n (cx === 6 && cy === 6) || (cx === 6 && cy === grid.size - 7) || (cx === grid.size - 7 && cy === 6);\n if (!isCorner) drawAlignment(grid, cx, cy);\n }\n reserveFormatAreas(grid);\n reserveVersionAreas(grid, version);\n}\n\n/** Place codeword bits into non-function modules via the zigzag scan. */\nexport function placeData(grid: QrGrid, codewords: readonly number[]): void {\n const size = grid.size;\n const totalBits = codewords.length * 8;\n let bitIndex = 0;\n let upward = true;\n for (let right = size - 1; right >= 1; right -= 2) {\n if (right === 6) right = 5; // skip the vertical timing column\n for (let vert = 0; vert < size; vert++) {\n for (let j = 0; j < 2; j++) {\n const x = right - j;\n const y = upward ? size - 1 - vert : vert;\n if (grid.isFunction[y][x]) continue;\n grid.modules[y][x] = bitIndex < totalBits && ((codewords[bitIndex >>> 3] >>> (7 - (bitIndex & 7))) & 1) === 1;\n bitIndex++;\n }\n }\n upward = !upward;\n }\n}\n","/**\n * GF(2⁸) arithmetic over the QR primitive polynomial x⁸+x⁴+x³+x²+1 (0x11D).\n * Tables are built once at module load: `EXP[i] = αⁱ` for generator α = 2.\n */\n\nconst PRIMITIVE = 0x11d;\n\nconst EXP = new Uint8Array(512);\nconst LOG = new Uint8Array(256);\n\n{\n let x = 1;\n for (let i = 0; i < 255; i++) {\n EXP[i] = x;\n LOG[x] = i;\n x <<= 1;\n if (x & 0x100) x ^= PRIMITIVE;\n }\n // Duplicate the cycle so `EXP[log(a) + log(b)]` never needs a mod.\n for (let i = 255; i < 512; i++) EXP[i] = EXP[i - 255];\n}\n\n/** `a * b` in GF(256); `0` when either operand is 0. */\nexport function gfMultiply(a: number, b: number): number {\n return a === 0 || b === 0 ? 0 : EXP[LOG[a] + LOG[b]];\n}\n\n/** `αⁱ` — the i-th power of the generator. `i` may exceed 254 (wraps). */\nexport function gfExp(i: number): number {\n return EXP[i % 255];\n}\n\n/** Polynomial evaluation in GF(256): Σ coeffᵢ·xⁱ with coeff[0] highest-degree. */\nexport function gfPolyEval(coeffs: readonly number[], x: number): number {\n let y = 0;\n for (const c of coeffs) y = gfMultiply(y, x) ^ c;\n return y;\n}\n\n/** Multiply two polynomials (coefficients highest-degree first). */\nexport function gfPolyMultiply(p: readonly number[], q: readonly number[]): number[] {\n const out = new Array<number>(p.length + q.length - 1).fill(0);\n for (let i = 0; i < p.length; i++) for (let j = 0; j < q.length; j++) out[i + j] ^= gfMultiply(p[i], q[j]);\n return out;\n}\n","import { gfExp, gfMultiply, gfPolyMultiply } from './_galois';\n\n/**\n * Reed–Solomon error-correction codewords over GF(256).\n * The generator polynomial for `degree` EC codewords is ∏ᵢ₌₀..degree₋₁ (x − αⁱ);\n * results are cached per degree (max 30 per ISO Table 9).\n */\n\nconst generatorCache = new Map<number, readonly number[]>();\n\n/** Generator polynomial coefficients (highest-degree first, leading 1 kept). */\nfunction generatorPoly(degree: number): readonly number[] {\n const poly = generatorCache.get(degree);\n if (poly) return poly;\n let g = [1];\n for (let i = 0; i < degree; i++) g = gfPolyMultiply(g, [1, gfExp(i)]);\n generatorCache.set(degree, g);\n return g;\n}\n\n/** EC codewords for one data block: remainder of data·x^degree ÷ generator. */\nexport function ecCodewords(data: readonly number[], degree: number): number[] {\n const gen = generatorPoly(degree); // gen[0] === 1\n const rem = new Array<number>(degree).fill(0);\n for (const b of data) {\n const factor = b ^ rem[0];\n rem.copyWithin(0, 1);\n rem[degree - 1] = 0;\n if (factor !== 0) for (let j = 0; j < degree; j++) rem[j] ^= gfMultiply(gen[j + 1], factor);\n }\n return rem;\n}\n","import { ALPHANUMERIC_CHARSET, CHAR_COUNT_BITS, dataCodewords, MODE_BITS, versionGroup } from './_tables';\nimport type { QrErrorCorrection, QrMode } from './types';\n\n/**\n * Data-segment assembly: one segment (single mode) covering the whole input,\n * followed by terminator, byte alignment, and 0xEC/0x11 padding (§7.4–7.5).\n * Kanji and multi-segment optimization are out of scope.\n */\n\nconst textEncoder = new TextEncoder();\n\n/**\n * Payload prepared for its mode: text for numeric/alphanumeric, raw bytes for\n * byte mode. Byte mode never round-trips through a string, so invalid UTF-8\n * input survives encoding untouched.\n */\nexport type QrPayload =\n | { readonly mode: 'numeric' | 'alphanumeric'; readonly text: string }\n | { readonly mode: 'byte'; readonly bytes: Uint8Array };\n\n/** Interpret `text` as `mode` — UTF-8-encoding only for byte mode. */\nexport const payloadFromText = (text: string, mode: QrMode): QrPayload =>\n mode === 'byte' ? { bytes: textEncoder.encode(text), mode: 'byte' } : { mode, text };\n\n/** Raw binary payload; always byte mode. */\nexport const payloadFromBytes = (bytes: Uint8Array): QrPayload => ({ bytes, mode: 'byte' });\n\n/** Value carried in the character-count field. */\nexport function payloadLength(payload: QrPayload): number {\n return payload.mode === 'byte' ? payload.bytes.length : payload.text.length;\n}\n\n/** Growable bit stream; `bytes` is valid only after `padToByte()`. */\nexport class BitStream {\n private bits: number[] = [];\n\n get length(): number {\n return this.bits.length;\n }\n\n append(value: number, width: number): void {\n for (let i = width - 1; i >= 0; i--) this.bits.push((value >>> i) & 1);\n }\n\n padToByte(): void {\n while (this.bits.length % 8 !== 0) this.bits.push(0);\n }\n\n toBytes(): number[] {\n const out: number[] = [];\n for (let i = 0; i < this.bits.length; i += 8) {\n let b = 0;\n for (let j = 0; j < 8; j++) b = (b << 1) | this.bits[i + j];\n out.push(b);\n }\n return out;\n }\n}\n\n/** Most compact mode able to encode the whole text. */\nexport function detectMode(text: string): QrMode {\n if (/^\\d+$/.test(text)) return 'numeric';\n for (const ch of text) if (!ALPHANUMERIC_CHARSET.includes(ch)) return 'byte';\n return 'alphanumeric';\n}\n\n/** Payload bits for the segment body (without mode/count headers). */\nexport function dataBitLength(payload: QrPayload): number {\n switch (payload.mode) {\n case 'numeric':\n return (\n Math.floor(payload.text.length / 3) * 10 +\n (payload.text.length % 3 === 1 ? 4 : payload.text.length % 3 === 2 ? 7 : 0)\n );\n case 'alphanumeric':\n return Math.floor(payload.text.length / 2) * 11 + (payload.text.length % 2) * 6;\n case 'byte':\n return payload.bytes.length * 8;\n }\n}\n\n/** Append mode indicator, char count, and payload bits. */\nexport function appendSegment(stream: BitStream, payload: QrPayload, version: number): void {\n stream.append(MODE_BITS[payload.mode], 4);\n stream.append(payloadLength(payload), CHAR_COUNT_BITS[payload.mode][versionGroup(version)]);\n switch (payload.mode) {\n case 'numeric':\n for (let i = 0; i < payload.text.length; ) {\n const n = Math.min(3, payload.text.length - i);\n stream.append(Number.parseInt(payload.text.slice(i, i + n), 10), n === 3 ? 10 : n === 2 ? 7 : 4);\n i += n;\n }\n break;\n case 'alphanumeric':\n for (let i = 0; i < payload.text.length; ) {\n if (i + 1 < payload.text.length) {\n stream.append(\n ALPHANUMERIC_CHARSET.indexOf(payload.text[i]) * 45 + ALPHANUMERIC_CHARSET.indexOf(payload.text[i + 1]),\n 11,\n );\n i += 2;\n } else {\n stream.append(ALPHANUMERIC_CHARSET.indexOf(payload.text[i]), 6);\n i += 1;\n }\n }\n break;\n case 'byte':\n for (const b of payload.bytes) stream.append(b, 8);\n break;\n }\n}\n\n/** Capacity in bits for the data area of (version, level). */\nexport const dataCapacityBits = (version: number, level: QrErrorCorrection): number =>\n dataCodewords(version, level) * 8;\n\n/** Bits a segment occupies at `version`: header + payload, before terminator. */\nexport function segmentBits(payload: QrPayload, version: number): number {\n return 4 + CHAR_COUNT_BITS[payload.mode][versionGroup(version)] + dataBitLength(payload);\n}\n\n/**\n * Full data-codeword sequence for (version, level): segment + terminator +\n * alignment + pad bytes. Caller guarantees the segment fits.\n */\nexport function buildDataCodewords(payload: QrPayload, version: number, level: QrErrorCorrection): number[] {\n const stream = new BitStream();\n appendSegment(stream, payload, version);\n const capacity = dataCapacityBits(version, level);\n stream.append(0, Math.min(4, capacity - stream.length)); // terminator\n stream.padToByte();\n const bytes = stream.toBytes();\n const pad = [0xec, 0x11];\n for (let i = 0; bytes.length < dataCodewords(version, level); i++) bytes.push(pad[i % 2]);\n return bytes;\n}\n","import { drawFormatInfo, drawVersionInfo } from './_format';\nimport { applyMask, penaltyScore } from './_mask';\nimport { createGrid, drawFunctionPatterns, placeData } from './_matrix';\nimport { ecCodewords } from './_reed-solomon';\nimport {\n buildDataCodewords,\n detectMode,\n payloadFromBytes,\n payloadFromText,\n payloadLength,\n type QrPayload,\n segmentBits,\n} from './_segments';\nimport {\n ALPHANUMERIC_CHARSET,\n CHAR_COUNT_BITS,\n dataCodewords,\n ecCodewordsPerBlock,\n matrixSize,\n numEcBlocks,\n totalCodewords,\n versionGroup,\n} from './_tables';\nimport { SigilCapacityError, SigilOptionError } from './errors';\nimport type { QrEncodeOptions, QrErrorCorrection, QrMatrix, QrMode } from './types';\n\nconst MAX_VERSION = 40;\n\nfunction checkOptions(options: QrEncodeOptions): void {\n const { version, minVersion, mask, errorCorrection } = options;\n const inRange = (v: number) => Number.isInteger(v) && v >= 1 && v <= MAX_VERSION;\n if (version !== undefined && !inRange(version))\n throw new SigilOptionError(`version must be an integer 1–${MAX_VERSION}, got ${version}`);\n if (minVersion !== undefined && !inRange(minVersion))\n throw new SigilOptionError(`minVersion must be an integer 1–${MAX_VERSION}, got ${minVersion}`);\n if (version !== undefined && minVersion !== undefined && minVersion > version)\n throw new SigilOptionError(`minVersion (${minVersion}) exceeds version (${version})`);\n if (mask !== undefined && (!Number.isInteger(mask) || mask < 0 || mask > 7))\n throw new SigilOptionError(`mask must be an integer 0–7, got ${mask}`);\n if (errorCorrection !== undefined && !'LMQH'.includes(errorCorrection))\n throw new SigilOptionError(`errorCorrection must be 'L', 'M', 'Q', or 'H'`);\n}\n\n/** Character capacity of (version, level, mode) — the `qrCapacity` core. */\nfunction capacityFor(version: number, level: QrErrorCorrection, mode: QrMode): number {\n const countBits = CHAR_COUNT_BITS[mode][versionGroup(version)];\n const usable = dataCodewords(version, level) * 8 - 4 - countBits;\n if (usable <= 0) return 0;\n switch (mode) {\n case 'numeric':\n return Math.floor(usable / 10) * 3 + (usable % 10 >= 7 ? 2 : usable % 10 >= 4 ? 1 : 0);\n case 'alphanumeric':\n return Math.floor(usable / 11) * 2 + (usable % 11 >= 6 ? 1 : 0);\n case 'byte':\n return Math.floor(usable / 8);\n }\n}\n\n/** Smallest version ≥ minVersion whose data area fits the segment, or `null`. */\nfunction pickVersion(payload: QrPayload, level: QrErrorCorrection, minVersion: number): number | null {\n for (let v = minVersion; v <= MAX_VERSION; v++) if (segmentBits(payload, v) <= dataCodewords(v, level) * 8) return v;\n return null;\n}\n\n/** The capacity error for a payload that does not fit at `version`. */\nfunction capacityError(payload: QrPayload, level: QrErrorCorrection, version: number): SigilCapacityError {\n const length = payloadLength(payload);\n const max = capacityFor(version, level, payload.mode);\n const unit = payload.mode === 'byte' ? 'bytes' : 'chars';\n return new SigilCapacityError(\n `Input of ${length} ${unit} exceeds QR capacity (${max} ${unit} at version ${version}-${level})`,\n length,\n max,\n version,\n );\n}\n\n/** Split data codewords into EC blocks and interleave data + EC (§7.6). */\nfunction interleaveBlocks(data: readonly number[], version: number, level: QrErrorCorrection): number[] {\n const numBlocks = numEcBlocks(version, level);\n const ecLen = ecCodewordsPerBlock(version, level);\n const rawLen = totalCodewords(version);\n const shortLen = Math.floor(rawLen / numBlocks) - ecLen; // data codewords in a short block\n const numLong = rawLen % numBlocks; // long blocks carry one extra data codeword\n\n const blocks: number[][] = [];\n let offset = 0;\n for (let b = 0; b < numBlocks; b++) {\n const isLong = b >= numBlocks - numLong;\n const dat = data.slice(offset, offset + shortLen + (isLong ? 1 : 0));\n offset += dat.length;\n const ecc = ecCodewords(dat, ecLen);\n // Short blocks get a pad slot so every block array shares one length;\n // the slot is skipped during interleave below.\n blocks.push(isLong ? [...dat, ...ecc] : [...dat, 0, ...ecc]);\n }\n\n const out: number[] = [];\n for (let i = 0; i < blocks[0].length; i++)\n for (let b = 0; b < numBlocks; b++) {\n // Skip the pad slot on short blocks (index = shortLen).\n if (i !== shortLen || b >= numBlocks - numLong) out.push(blocks[b][i]);\n }\n return out;\n}\n\nfunction freezeMatrix(grid: readonly (readonly boolean[])[], meta: Omit<QrMatrix, 'get'>): QrMatrix {\n const modules = grid.map((row) => Object.freeze([...row]));\n Object.freeze(modules);\n return Object.freeze({\n ...meta,\n get: (x: number, y: number) => (x >= 0 && y >= 0 && x < meta.size && y < meta.size ? modules[y][x] : false),\n });\n}\n\n/**\n * Encode `data` into a QR Model 2 symbol. Pure and synchronous.\n * Strings pick the most compact mode; `Uint8Array` is raw binary and always\n * byte mode, encoded as-is — no UTF-8 round-trip. Byte mode is UTF-8 without\n * an ECI header for string input — the industry-standard assumption.\n */\nexport function encodeQr(data: string | Uint8Array, options: QrEncodeOptions = {}): QrMatrix {\n checkOptions(options);\n if (data.length === 0) throw new SigilOptionError('Cannot encode an empty input');\n\n const level = options.errorCorrection ?? 'M';\n if (typeof data !== 'string' && options.mode !== undefined && options.mode !== 'byte')\n throw new SigilOptionError('Uint8Array input can only be encoded in byte mode');\n const mode = options.mode ?? (typeof data === 'string' ? detectMode(data) : 'byte');\n if (typeof data === 'string' && !isModeCompatible(data, mode))\n throw new SigilOptionError(`Input cannot be encoded in ${mode} mode`);\n const payload = typeof data === 'string' ? payloadFromText(data, mode) : payloadFromBytes(data);\n\n const version = options.version ?? pickVersion(payload, level, options.minVersion ?? 1);\n if (version === null || segmentBits(payload, version) > dataCodewords(version, level) * 8)\n throw capacityError(payload, level, options.version ?? MAX_VERSION);\n\n const codewords = interleaveBlocks(buildDataCodewords(payload, version, level), version, level);\n const grid = createGrid(matrixSize(version));\n drawFunctionPatterns(grid, version);\n placeData(grid, codewords);\n\n // Try every mask (or the forced one), keep the lowest penalty. Each candidate\n // is undone by the idempotent XOR, and the final drawFormatInfo below rewrites\n // every format module, so candidates never leak into each other.\n const candidates = options.mask !== undefined ? [options.mask] : [0, 1, 2, 3, 4, 5, 6, 7];\n let bestMask = candidates[0];\n let bestScore = Number.POSITIVE_INFINITY;\n for (const m of candidates) {\n applyMask(grid, m);\n drawFormatInfo(grid, level, m);\n const score = penaltyScore(grid);\n if (score < bestScore) {\n bestScore = score;\n bestMask = m;\n }\n applyMask(grid, m); // undo\n }\n\n // The grid is unmasked again — draw the winning candidate once, finally.\n applyMask(grid, bestMask);\n drawFormatInfo(grid, level, bestMask);\n drawVersionInfo(grid, version);\n\n return freezeMatrix(grid.modules, {\n errorCorrection: level,\n mask: bestMask,\n mode,\n size: grid.size,\n version,\n });\n}\n\n/** Whether `text` is representable in `mode` (used when the mode is forced). */\nfunction isModeCompatible(text: string, mode: QrMode): boolean {\n if (mode === 'numeric') return /^\\d+$/.test(text);\n if (mode === 'alphanumeric') return [...text].every((ch) => ALPHANUMERIC_CHARSET.includes(ch));\n return true;\n}\n\n/** Max characters/bytes encodable at (version, level, mode). */\nexport function qrCapacity(version: number, errorCorrection: QrErrorCorrection, mode: QrMode): number {\n if (!Number.isInteger(version) || version < 1 || version > MAX_VERSION)\n throw new SigilOptionError(`version must be an integer 1–${MAX_VERSION}, got ${version}`);\n return capacityFor(version, errorCorrection, mode);\n}\n","import { SigilDisposedError, SigilError, SigilPermissionError, SigilUnsupportedError } from './errors';\nimport type { QrDetector, QrScanner, QrScannerOptions, QrScannerStatus, QrScanResult, SigilEvent } from './types';\n\n/**\n * Scanning via the native `BarcodeDetector` API — a thin lifecycle wrapper.\n * Feature detection is lazy so importing the package is always safe (SSR).\n * No from-scratch image decoder: unsupported environments get\n * `SigilUnsupportedError` at `start()`/`detectQr()`, never at import.\n */\n\ninterface BarcodeDetectorLike {\n detect(\n source: ImageBitmapSource,\n ): Promise<ReadonlyArray<{ rawValue: string; cornerPoints?: ReadonlyArray<{ x: number; y: number }> }>>;\n}\n\ninterface BarcodeDetectorCtor {\n getSupportedFormats?(): Promise<readonly string[]>;\n new (options?: { formats?: string[] }): BarcodeDetectorLike;\n}\n\nconst globalScope = globalThis as { BarcodeDetector?: BarcodeDetectorCtor };\n\nconst barcodeDetector = (): BarcodeDetectorCtor | undefined => globalScope.BarcodeDetector;\n\n/** Sync check: `BarcodeDetector` exists. Format support needs the async variant. */\nexport function isQrScanSupported(): boolean {\n return typeof barcodeDetector() === 'function';\n}\n\n/** Full check: `BarcodeDetector` exists and reports `qr_code` support. */\nexport async function qrScanSupport(): Promise<boolean> {\n const ctor = barcodeDetector();\n if (typeof ctor !== 'function') return false;\n if (typeof ctor.getSupportedFormats !== 'function') return true;\n try {\n return (await ctor.getSupportedFormats()).includes('qr_code');\n } catch {\n return false;\n }\n}\n\n/** One-shot detection on an image source; `null` when no code is found. */\nexport async function detectQr(\n source: ImageBitmapSource,\n options: { signal?: AbortSignal; detector?: QrDetector } = {},\n): Promise<QrScanResult | null> {\n options.signal?.throwIfAborted();\n const ctor = barcodeDetector();\n const detector = options.detector ?? (ctor ? new ctor({ formats: ['qr_code'] }) : undefined);\n if (!detector) throw new SigilUnsupportedError('BarcodeDetector is not available in this environment');\n const results = await detector.detect(source);\n options.signal?.throwIfAborted();\n const first = results[0];\n return first ? { cornerPoints: first.cornerPoints, value: first.rawValue } : null;\n}\n\nexport function createQrScanner(options: QrScannerOptions): QrScanner {\n const media = options.mediaDevices ?? globalThis.navigator?.mediaDevices;\n const once = options.once ?? true;\n const intervalMs = options.intervalMs ?? 200;\n const disposal = new AbortController();\n const tappers = new Set<(event: SigilEvent) => void>();\n const handlers = new Set<(result: QrScanResult) => void>();\n\n let status: QrScannerStatus = 'idle';\n let stream: MediaStream | null = null;\n let timer: ReturnType<typeof setInterval> | null = null;\n let busy = false;\n let detector: Promise<QrDetector> | undefined;\n\n const emit = (event: SigilEvent): void => {\n if (tappers.size === 0) return;\n for (const handler of [...tappers]) {\n try {\n handler(event);\n } catch {\n // Observability must never affect behavior.\n }\n }\n };\n\n const setStatus = (next: QrScannerStatus): void => {\n if (status === next) return;\n status = next;\n emit({ status: next, type: 'status-change' });\n };\n\n // Read through a function: status changes across awaits via closures, and a\n // direct read would be narrowed to the pre-await value by the compiler.\n const isStarting = (): boolean => status === 'starting';\n\n const stopTracks = (): void => {\n if (timer !== null) {\n clearInterval(timer);\n timer = null;\n }\n if (stream) {\n for (const track of stream.getTracks()) track.stop();\n stream = null;\n }\n options.video.srcObject = null;\n };\n\n const fail = (error: SigilError): void => {\n emit({ error, type: 'error' });\n stopTracks();\n setStatus('idle');\n };\n\n // Created on first start() so a missing BarcodeDetector never rejects a\n // promise nobody awaits (construction must stay side-effect-free).\n const getDetector = (): Promise<QrDetector> => {\n detector ??= (async () => {\n if (options.detector) return options.detector;\n const ctor = barcodeDetector();\n if (typeof ctor !== 'function')\n throw new SigilUnsupportedError('BarcodeDetector is not available in this environment');\n return new ctor({ formats: ['qr_code'] });\n })();\n return detector;\n };\n\n const tick = async (): Promise<void> => {\n if (status !== 'scanning' || stream === null) return;\n const video = options.video;\n if (video.readyState < 2 /* HAVE_CURRENT_DATA */) {\n emit({ reason: 'not-ready', type: 'frame-skipped' });\n return;\n }\n if (busy) {\n emit({ reason: 'busy', type: 'frame-skipped' });\n return;\n }\n busy = true;\n const started = Date.now();\n try {\n const qrDetector = await getDetector();\n const results = await qrDetector.detect(video);\n const first = results[0];\n if (first) {\n const result: QrScanResult = { cornerPoints: first.cornerPoints, value: first.rawValue };\n emit({ elapsedMs: Date.now() - started, type: 'detect', value: result.value });\n for (const handler of [...handlers]) handler(result);\n if (once) {\n stopTracks();\n setStatus('idle');\n }\n }\n } catch (error) {\n fail(error instanceof SigilError ? error : new SigilError('QR detection failed', { cause: error }));\n } finally {\n busy = false;\n }\n };\n\n const api: QrScanner = {\n get disposalSignal() {\n return disposal.signal;\n },\n dispose() {\n if (status === 'disposed') return;\n emit({ type: 'dispose' });\n stopTracks();\n handlers.clear();\n tappers.clear();\n setStatus('disposed');\n disposal.abort();\n },\n get disposed() {\n return status === 'disposed';\n },\n onResult(handler) {\n if (status === 'disposed') return () => {};\n handlers.add(handler);\n return () => handlers.delete(handler);\n },\n async start() {\n if (status === 'disposed') throw new SigilDisposedError('Scanner is disposed');\n if (status === 'starting' || status === 'scanning') return;\n if (!media || typeof media.getUserMedia !== 'function')\n throw new SigilUnsupportedError('getUserMedia is not available in this environment');\n // Surface a missing detector at start() (not construction) per contract.\n await getDetector();\n options.signal?.throwIfAborted();\n setStatus('starting');\n let newStream: MediaStream;\n try {\n newStream = await media.getUserMedia({ video: options.constraints ?? { facingMode: 'environment' } });\n } catch (error) {\n setStatus('idle');\n if (error instanceof DOMException && error.name === 'NotAllowedError')\n throw new SigilPermissionError('Camera permission denied', { cause: error });\n throw error instanceof Error ? error : new SigilError('Camera request failed', { cause: error });\n }\n // stop()/dispose() during the permission prompt must not resurrect the scanner.\n if (!isStarting()) {\n for (const track of newStream.getTracks()) track.stop();\n return;\n }\n stream = newStream;\n options.video.srcObject = stream;\n await options.video.play().catch(() => {});\n if (!isStarting()) {\n stopTracks();\n return;\n }\n setStatus('scanning');\n timer = setInterval(() => void tick(), intervalMs);\n void tick();\n },\n get status() {\n return status;\n },\n stop() {\n if (status === 'disposed') return;\n stopTracks();\n setStatus('idle');\n },\n tap(handler, tapOptions) {\n if (status === 'disposed') return () => {};\n tappers.add(handler);\n const off = () => tappers.delete(handler);\n tapOptions?.signal?.addEventListener('abort', off, { once: true });\n return off;\n },\n [Symbol.dispose]() {\n api.dispose();\n },\n };\n\n if (options.signal) {\n const onAbort = (): void => api.stop();\n options.signal.addEventListener('abort', onAbort, { once: true });\n // A long-lived signal must not retain the scanner past dispose().\n disposal.signal.addEventListener('abort', () => options.signal?.removeEventListener('abort', onAbort), {\n once: true,\n });\n }\n return api;\n}\n","import type { QrMatrix, QrSvgOptions } from './types';\n\n/**\n * SVG rendering — pure string output, safe in any environment.\n * The optimized path merges each row's dark-module runs into `M x y hW v1 h-W z`\n * spans; `optimizePath: false` emits one subpath per module.\n */\n\nconst esc = (s: string): string =>\n s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');\n\nexport function toSvg(matrix: QrMatrix, options: QrSvgOptions = {}): string {\n const margin = options.margin ?? 4;\n const scale = options.scale ?? 1;\n const dark = options.dark ?? 'currentColor';\n const light = options.light ?? 'transparent';\n const optimize = options.optimizePath ?? true;\n const dim = (matrix.size + margin * 2) * scale;\n\n const parts: string[] = [`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${dim} ${dim}\" role=\"img\"`];\n if (options.label !== undefined) {\n parts.push(` aria-label=\"${esc(options.label)}\"`);\n }\n parts.push(` shape-rendering=\"crispEdges\">`);\n if (options.label !== undefined) parts.push(`<title>${esc(options.label)}</title>`);\n if (light !== 'transparent') parts.push(`<rect width=\"${dim}\" height=\"${dim}\" fill=\"${light}\"/>`);\n\n const path: string[] = [];\n for (let y = 0; y < matrix.size; y++) {\n let x = 0;\n while (x < matrix.size) {\n if (!matrix.get(x, y)) {\n x++;\n continue;\n }\n if (optimize) {\n let run = 1;\n while (x + run < matrix.size && matrix.get(x + run, y)) run++;\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${run * scale}v${scale}h${-run * scale}z`);\n x += run;\n } else {\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${scale}v${scale}h${-scale}z`);\n x++;\n }\n }\n }\n parts.push(`<path d=\"${path.join('')}\" fill=\"${dark}\"/>`);\n parts.push('</svg>');\n return parts.join('');\n}\n"],"mappings":"AAIA,IAAa,WAAb,cAAgC,KAAM,CACpC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,mBAAb,cAAwC,UAAW,CACjD,MACA,SACA,QAEA,YAAY,EAAiB,EAAe,EAAkB,EAAiB,EAAqB,CAClG,MAAM,EAAS,CAAI,EACnB,KAAK,MAAQ,EACb,KAAK,SAAW,EAChB,KAAK,QAAU,CACjB,CACF,EAGa,iBAAb,cAAsC,UAAW,CAAC,EAMrC,sBAAb,cAA2C,UAAW,CAAC,EAG1C,qBAAb,cAA0C,UAAW,CAAC,EAGzC,mBAAb,cAAwC,UAAW,CAAC,EC9BpD,SAAgB,aAAa,EAAkB,EAA2B,EAA2B,CAAC,EAAW,CAC/G,IAAM,EAAS,EAAQ,QAAU,EAC3B,EAAQ,EAAQ,OAAS,EACzB,EAAO,EAAQ,MAAQ,UACvB,EAAQ,EAAQ,OAAS,UACzB,GAAW,EAAO,KAAO,EAAS,GAAK,EACvC,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,QAAU,IAAA,IACpB,EAAM,KAAK,gBAAgB,IAAI,EAAQ,KAAK,EAAE,EAAE,EAElD,EAAM,KAAK,gCAAgC,EACvC,EAAQ,QAAU,IAAA,IAAW,EAAM,KAAK,UAAU,IAAI,EAAQ,KAAK,EAAE,SAAS,EAC9E,IAAU,eAAe,EAAM,KAAK,gBAAgB,EAAI,YAAY,EAAI,UAAU,EAAM,IAAI,EAEhG,IAAM,EAAiB,CAAC,EACxB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,KAAM,IAAK,CACpC,IAAI,EAAI,EACR,KAAO,EAAI,EAAO,MAAM,CACtB,GAAI,CAAC,EAAO,IAAI,EAAG,CAAC,EAAG,CACrB,IACA,QACF,CACA,GAAI,EAAU,CACZ,IAAI,EAAM,EACV,KAAO,EAAI,EAAM,EAAO,MAAQ,EAAO,IAAI,EAAI,EAAK,CAAC,GAAG,IACxD,EAAK,KAAK,KAAK,EAAI,GAAU,EAAM,IAAI,EAAI,GAAU,EAAM,GAAG,EAAM,EAAM,GAAG,EAAM,GAAG,CAAC,EAAM,EAAM,EAAE,EACrG,GAAK,CACP,MACE,EAAK,KAAK,KAAK,EAAI,GAAU,EAAM,IAAI,EAAI,GAAU,EAAM,GAAG,EAAM,GAAG,EAAM,GAAG,CAAC,EAAM,EAAE,EACzF,GAEJ,CACF,CAGA,OAFA,EAAM,KAAK,YAAY,EAAK,KAAK,EAAE,EAAE,UAAU,EAAK,IAAI,EACxD,EAAM,KAAK,QAAQ,EACZ,EAAM,KAAK,EAAE,CACtB"}
|
|
1
|
+
{"version":3,"file":"sigil.js","names":[],"sources":["../src/errors.ts","../src/canvas.ts","../src/_tables.ts","../src/_format.ts","../src/_mask.ts","../src/_matrix.ts","../src/_galois.ts","../src/_reed-solomon.ts","../src/_segments.ts","../src/encode.ts","../src/scan.ts","../src/svg.ts"],"sourcesContent":["/**\n * Base class for all sigil errors.\n * Use `instanceof SigilError` to catch any sigil-originated error in one branch.\n */\nexport class SigilError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when input data does not fit in the requested version/level. */\nexport class SigilCapacityError extends SigilError {\n readonly bytes: number;\n readonly maxBytes: number;\n readonly version: number;\n\n constructor(message: string, bytes: number, maxBytes: number, version: number, opts?: ErrorOptions) {\n super(message, opts);\n this.bytes = bytes;\n this.maxBytes = maxBytes;\n this.version = version;\n }\n}\n\n/** Thrown for an invalid option: version/minVersion out of range, mask outside 0–7. */\nexport class SigilOptionError extends SigilError {}\n\n/**\n * Thrown when the environment lacks `BarcodeDetector`, `getUserMedia`, or QR\n * format support. Feature-detect with `isQrScanSupported()`/`qrScanSupport()`.\n */\nexport class SigilUnsupportedError extends SigilError {}\n\n/** Thrown when camera access is denied (wraps `NotAllowedError`). */\nexport class SigilPermissionError extends SigilError {}\n\n/** Thrown when a disposed scanner is used. */\nexport class SigilDisposedError extends SigilError {}\n","import { SigilUnsupportedError } from './errors';\nimport type { QrCanvasOptions, QrMatrix } from './types';\n\n/**\n * Canvas rendering: the only DOM-touching output path.\n * Resizes the canvas to `(size + 2*margin) * scale` CSS pixels, backing-store\n * scaled by `devicePixelRatio`, and paints one `fillRect` per dark module.\n * Returns the CSS pixel size so callers can size wrappers.\n */\nexport function drawToCanvas(matrix: QrMatrix, canvas: HTMLCanvasElement, options: QrCanvasOptions = {}): number {\n const margin = options.margin ?? 4;\n const scale = options.scale ?? 1;\n const dark = options.dark ?? '#000000';\n const light = options.light ?? '#ffffff';\n const cssSize = (matrix.size + margin * 2) * scale;\n const dpr = globalThis.devicePixelRatio || 1;\n\n canvas.width = cssSize * dpr;\n canvas.height = cssSize * dpr;\n canvas.style.width = `${cssSize}px`;\n canvas.style.height = `${cssSize}px`;\n\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new SigilUnsupportedError('Canvas 2D context unavailable');\n ctx.scale(dpr, dpr);\n ctx.fillStyle = light;\n ctx.fillRect(0, 0, cssSize, cssSize);\n ctx.fillStyle = dark;\n for (let y = 0; y < matrix.size; y++)\n for (let x = 0; x < matrix.size; x++)\n if (matrix.get(x, y)) ctx.fillRect((x + margin) * scale, (y + margin) * scale, scale, scale);\n return cssSize;\n}\n","import type { QrErrorCorrection, QrMode } from './types';\n\n/**\n * QR Model 2 lookup tables, transcribed from ISO/IEC 18004:2015:\n * - `EC_CODEWORDS_PER_BLOCK` / `NUM_EC_BLOCKS`: Table 9 (error-correction\n * characteristics). Stored as per-block EC codewords and block count; the\n * group-1/group-2 split is derived, since all blocks share one EC length.\n * - `alignmentPatternPositions`: Table E.1, computed by the spec formula.\n * - `CHAR_COUNT_BITS`: Table 3 (character-count indicator bit widths).\n * - `FORMAT_EC_BITS`: Table 10 (2-bit level field inside format information).\n *\n * `tables.test.ts` cross-checks every entry against the raw-module formula, so\n * a transcription slip fails the consistency test before the decode oracle runs.\n */\n\n/** Index order used by the table rows below. */\nexport const EC_LEVELS = ['L', 'M', 'Q', 'H'] as const;\n\nexport const ALPHANUMERIC_CHARSET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';\n\n/** Mode indicators (Table 2). */\nexport const MODE_BITS: Record<QrMode, number> = {\n alphanumeric: 0b0010,\n byte: 0b0100,\n numeric: 0b0001,\n};\n\n/** Character-count indicator widths for version groups 1–9 / 10–26 / 27–40. */\nexport const CHAR_COUNT_BITS: Record<QrMode, readonly [number, number, number]> = {\n alphanumeric: [9, 11, 13],\n byte: [8, 16, 16],\n numeric: [10, 12, 14],\n};\n\n/** EC level bits inside format information (L=01, M=00, Q=11, H=10). */\nexport const FORMAT_EC_BITS: Record<QrErrorCorrection, number> = { H: 0b10, L: 0b01, M: 0b00, Q: 0b11 };\n\n/** Row 0 = L, row 1 = M, row 2 = Q, row 3 = H; column 0 unused (versions start at 1). */\nexport const EC_CODEWORDS_PER_BLOCK: ReadonlyArray<ReadonlyArray<number>> = [\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, 30, 26, 28, 30, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\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, 28, 28, 28, 28, 28, 28,\n 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ],\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, 30, 30, 30, 28, 30, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\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, 30, 30, 30, 30, 30, 30,\n 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n];\n\nexport const NUM_EC_BLOCKS: ReadonlyArray<ReadonlyArray<number>> = [\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, 14, 15, 16, 17, 18, 19,\n 19, 20, 21, 22, 24, 25,\n ],\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, 25, 26, 28, 29, 31,\n 33, 35, 37, 38, 40, 43, 45, 47, 49,\n ],\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, 34, 34, 35, 38, 40, 43,\n 45, 48, 51, 53, 56, 59, 62, 65, 68,\n ],\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, 37, 40, 42, 45, 48,\n 51, 56, 59, 62, 65, 68, 71, 74, 77, 81,\n ],\n];\n\nconst ecIndex = (level: QrErrorCorrection): number => EC_LEVELS.indexOf(level);\n\n/** Total modules per side. */\nexport const matrixSize = (version: number): number => version * 4 + 17;\n\n/** Alignment-pattern center coordinates (Table E.1 formula). */\nexport function alignmentPatternPositions(version: number): readonly number[] {\n if (version === 1) return [];\n const numAlign = Math.floor(version / 7) + 2;\n const step = version === 32 ? 26 : Math.ceil((version * 4 + 4) / (numAlign * 2 - 2)) * 2;\n const result = [6];\n for (let pos = version * 4 + 10; result.length < numAlign; pos -= step) result.splice(1, 0, pos);\n return result;\n}\n\n/**\n * Total raw modules available for data + EC + remainder bits, derived from the\n * symbol geometry (Table 1 / Annex A): full grid minus finders, separators,\n * timing, alignment, dark module, format and version information.\n */\nexport function rawDataModules(version: number): number {\n let result = (16 * version + 128) * version + 64;\n if (version >= 2) {\n const numAlign = Math.floor(version / 7) + 2;\n result -= (25 * numAlign - 10) * numAlign - 55;\n if (version >= 7) result -= 36;\n }\n return result;\n}\n\n/** Total codewords (data + EC) for a version. */\nexport const totalCodewords = (version: number): number => Math.floor(rawDataModules(version) / 8);\n\n/** Leftover bits after the codeword stream (0, 3, 4, or 7 by version). */\nexport const remainderBits = (version: number): number => rawDataModules(version) % 8;\n\nexport function ecCodewordsPerBlock(version: number, level: QrErrorCorrection): number {\n return EC_CODEWORDS_PER_BLOCK[ecIndex(level)][version];\n}\n\nexport function numEcBlocks(version: number, level: QrErrorCorrection): number {\n return NUM_EC_BLOCKS[ecIndex(level)][version];\n}\n\n/** Data codewords for a (version, level) pair. */\nexport function dataCodewords(version: number, level: QrErrorCorrection): number {\n return totalCodewords(version) - ecCodewordsPerBlock(version, level) * numEcBlocks(version, level);\n}\n\n/** Version group for the character-count indicator: 0 → 1–9, 1 → 10–26, 2 → 27–40. */\nexport function versionGroup(version: number): 0 | 1 | 2 {\n return version <= 9 ? 0 : version <= 26 ? 1 : 2;\n}\n","import type { QrGrid } from './_matrix';\nimport { FORMAT_EC_BITS } from './_tables';\nimport type { QrErrorCorrection } from './types';\n\n/**\n * Format and version information (§7.9, Annexes C–D):\n * - Format: 5 data bits (2 EC + 3 mask) → BCH(15,5) remainder → XOR 0x5412,\n * written twice around the finders.\n * - Version (v≥7): 6 data bits → BCH(18,6) remainder, written twice in the\n * 6×3 blocks at top-right and bottom-left.\n */\n\nconst BCH_FORMAT_POLY = 0b10100110111; // x¹⁰+x⁸+x⁵+x⁴+x²+x+1\nconst BCH_FORMAT_MASK = 0b101010000010010; // 0x5412\nconst BCH_VERSION_POLY = 0b1111100100101; // x¹²+x¹¹+x¹⁰+x⁹+x⁸+x⁵+x²+1\n\n/** 15-bit format information word for (level, mask). */\nexport function formatInfoBits(level: QrErrorCorrection, mask: number): number {\n const data = (FORMAT_EC_BITS[level] << 3) | mask;\n let rem = data;\n for (let i = 0; i < 10; i++) rem = (rem << 1) ^ (((rem >>> 9) & 1) * BCH_FORMAT_POLY);\n return ((data << 10) | (rem & 0x3ff)) ^ BCH_FORMAT_MASK;\n}\n\n/** 18-bit version information word (version ≥ 7). */\nexport function versionInfoBits(version: number): number {\n let rem = version;\n for (let i = 0; i < 12; i++) rem = (rem << 1) ^ (((rem >>> 11) & 1) * BCH_VERSION_POLY);\n return (version << 12) | (rem & 0xfff);\n}\n\nconst setFunction = (grid: QrGrid, x: number, y: number, dark: boolean): void => {\n grid.modules[y][x] = dark;\n grid.isFunction[y][x] = true;\n};\n\n/** Write both copies of the 15-bit format word plus the dark module. */\nexport function drawFormatInfo(grid: QrGrid, level: QrErrorCorrection, mask: number): void {\n const size = grid.size;\n const bits = formatInfoBits(level, mask);\n const bit = (i: number) => ((bits >>> i) & 1) === 1;\n\n // First copy around the top-left finder.\n for (let i = 0; i <= 5; i++) setFunction(grid, 8, i, bit(i));\n setFunction(grid, 8, 7, bit(6));\n setFunction(grid, 8, 8, bit(7));\n setFunction(grid, 7, 8, bit(8));\n for (let i = 9; i < 15; i++) setFunction(grid, 14 - i, 8, bit(i));\n\n // Second copy: row 8 beside the top-right finder (bits 0–7),\n // column 8 beside the bottom-left finder (bits 8–14).\n for (let i = 0; i < 8; i++) setFunction(grid, size - 1 - i, 8, bit(i));\n for (let i = 8; i < 15; i++) setFunction(grid, 8, size - 15 + i, bit(i));\n\n // Always-dark module below the bottom-left strip.\n setFunction(grid, 8, size - 8, true);\n}\n\n/** Write both 6×3 version-information blocks (v≥7). */\nexport function drawVersionInfo(grid: QrGrid, version: number): void {\n if (version < 7) return;\n const size = grid.size;\n const bits = versionInfoBits(version);\n for (let i = 0; i < 18; i++) {\n const dark = ((bits >>> i) & 1) === 1;\n const a = size - 11 + (i % 3);\n const b = Math.floor(i / 3);\n setFunction(grid, a, b, dark); // top-right\n setFunction(grid, b, a, dark); // bottom-left\n }\n}\n","import type { QrGrid } from './_matrix';\n\n/**\n * Data masks and penalty scoring (§7.8.2–7.8.3):\n * eight mask functions XORed onto data modules only, then four penalty rules\n * (N1=3 runs, N2=3 blocks, N3=40 finder-like patterns, N4=10 dark ratio).\n */\n\ntype MaskFn = (x: number, y: number) => boolean;\n\nexport const MASK_FNS: readonly MaskFn[] = [\n (x, y) => (x + y) % 2 === 0,\n (_x, y) => y % 2 === 0,\n (x) => x % 3 === 0,\n (x, y) => (x + y) % 3 === 0,\n (x, y) => (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0,\n (x, y) => ((x * y) % 2) + ((x * y) % 3) === 0,\n (x, y) => (((x * y) % 2) + ((x * y) % 3)) % 2 === 0,\n (x, y) => (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,\n];\n\n/** XOR mask `m` onto every non-function module. Idempotent per mask. */\nexport function applyMask(grid: QrGrid, mask: number): void {\n const fn = MASK_FNS[mask];\n for (let y = 0; y < grid.size; y++)\n for (let x = 0; x < grid.size; x++)\n if (!grid.isFunction[y][x] && fn(x, y)) grid.modules[y][x] = !grid.modules[y][x];\n}\n\nconst PENALTY_N1 = 3;\nconst PENALTY_N2 = 3;\nconst PENALTY_N3 = 40;\nconst PENALTY_N4 = 10;\n\n// Runs of ≥5 same-color modules in a row or column: N1 + (run − 5).\nfunction penaltyRuns(grid: QrGrid): number {\n let penalty = 0;\n const line = (same: boolean, run: number): number => {\n if (!same && run >= 5) penalty += PENALTY_N1 + run - 5;\n return same ? run + 1 : 1;\n };\n for (let i = 0; i < grid.size; i++) {\n let runRow = 1;\n let runCol = 1;\n for (let j = 1; j < grid.size; j++) {\n runRow = line(grid.modules[i][j] === grid.modules[i][j - 1], runRow);\n runCol = line(grid.modules[j][i] === grid.modules[j - 1][i], runCol);\n }\n if (runRow >= 5) penalty += PENALTY_N1 + runRow - 5;\n if (runCol >= 5) penalty += PENALTY_N1 + runCol - 5;\n }\n return penalty;\n}\n\n// 2×2 blocks of a single color.\nfunction penaltyBlocks(grid: QrGrid): number {\n let penalty = 0;\n for (let y = 0; y < grid.size - 1; y++)\n for (let x = 0; x < grid.size - 1; x++) {\n const c = grid.modules[y][x];\n if (c === grid.modules[y][x + 1] && c === grid.modules[y + 1][x] && c === grid.modules[y + 1][x + 1])\n penalty += PENALTY_N2;\n }\n return penalty;\n}\n\n// 1:1:3:1:1 finder-like patterns with a 4-module light border on either side.\nfunction penaltyFinderLike(grid: QrGrid): number {\n const size = grid.size;\n let penalty = 0;\n const checkLine = (get: (i: number) => boolean): void => {\n for (let i = 0; i + 11 <= size; i++) {\n const window = Array.from({ length: 11 }, (_, k) => get(i + k));\n const coreA = [false, false, false, false, true, false, true, true, true, false, true];\n const coreB = [true, false, true, true, true, false, true, false, false, false, false];\n if (window.every((v, k) => v === coreA[k]) || window.every((v, k) => v === coreB[k])) penalty += PENALTY_N3;\n }\n };\n for (let y = 0; y < size; y++) checkLine((i) => grid.modules[y][i]);\n for (let x = 0; x < size; x++) checkLine((i) => grid.modules[i][x]);\n return penalty;\n}\n\n// Ratio of dark modules: each 5% step away from 50% costs N4.\nfunction penaltyRatio(grid: QrGrid): number {\n let dark = 0;\n for (const row of grid.modules) for (const m of row) if (m) dark++;\n const total = grid.size * grid.size;\n const k = Math.floor(Math.abs(dark * 20 - total * 10) / total);\n return k * PENALTY_N4;\n}\n\n/** Total penalty score for a fully masked matrix. */\nexport function penaltyScore(grid: QrGrid): number {\n return penaltyRuns(grid) + penaltyBlocks(grid) + penaltyFinderLike(grid) + penaltyRatio(grid);\n}\n","import { alignmentPatternPositions } from './_tables';\n\n/**\n * Module placement (§7.7–7.9, Annex E): function patterns are drawn first and\n * recorded in `isFunction`, then the codeword bit stream fills the remaining\n * modules in a two-column zigzag starting bottom-right, skipping column 6.\n */\n\nexport interface QrGrid {\n /** Modules owned by function patterns: skipped by data placement and masks. */\n readonly isFunction: boolean[][];\n /** Final module colors; `true` = dark. Mutable during construction. */\n modules: boolean[][];\n readonly size: number;\n}\n\nexport function createGrid(size: number): QrGrid {\n return {\n isFunction: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n modules: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n size,\n };\n}\n\nconst setFunction = (grid: QrGrid, x: number, y: number, dark: boolean): void => {\n grid.modules[y][x] = dark;\n grid.isFunction[y][x] = true;\n};\n\n/** 7×7 finder pattern plus the one-module separator ring, centered at (x+3, y+3). */\nfunction drawFinder(grid: QrGrid, x: number, y: number): void {\n for (let dy = -4; dy <= 4; dy++)\n for (let dx = -4; dx <= 4; dx++) {\n const xx = x + 3 + dx;\n const yy = y + 3 + dy;\n if (xx < 0 || yy < 0 || xx >= grid.size || yy >= grid.size) continue;\n const dist = Math.max(Math.abs(dx), Math.abs(dy));\n setFunction(grid, xx, yy, dist !== 2 && dist !== 4);\n }\n}\n\n/** Alternating timing pattern along row/col 6, between the finders. */\nfunction drawTiming(grid: QrGrid): void {\n for (let i = 8; i < grid.size - 8; i++) {\n const dark = i % 2 === 0;\n if (!grid.isFunction[6][i]) setFunction(grid, i, 6, dark);\n if (!grid.isFunction[i][6]) setFunction(grid, 6, i, dark);\n }\n}\n\n/** 5×5 alignment pattern centered at (cx, cy). */\nfunction drawAlignment(grid: QrGrid, cx: number, cy: number): void {\n for (let dy = -2; dy <= 2; dy++)\n for (let dx = -2; dx <= 2; dx++) setFunction(grid, cx + dx, cy + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n}\n\n/**\n * Reserve the 15 format-info modules around each finder (both copies) and the\n * 6×3 version-info blocks for v≥7: drawn later by `_format.ts`, but data\n * placement must skip them now.\n */\nfunction reserveFormatAreas(grid: QrGrid): void {\n const size = grid.size;\n // Around the top-left finder.\n for (let i = 0; i <= 8; i++) {\n if (i !== 6) {\n grid.isFunction[8][i] = true;\n grid.isFunction[i][8] = true;\n }\n }\n // Second copy: column 8 rows size-1..size-7 beside the bottom-left finder,\n // row 8 columns size-1..size-8 beside the top-right finder.\n for (let i = 0; i < 7; i++) grid.isFunction[size - 1 - i][8] = true;\n for (let i = 0; i < 8; i++) grid.isFunction[8][size - 1 - i] = true;\n // Always-dark module below the bottom-left format strip.\n grid.isFunction[size - 8][8] = true;\n}\n\nfunction reserveVersionAreas(grid: QrGrid, version: number): void {\n if (version < 7) return;\n const size = grid.size;\n for (let i = 0; i < 18; i++) {\n const a = size - 11 + (i % 3);\n const b = Math.floor(i / 3);\n grid.isFunction[b][a] = true; // top-right block\n grid.isFunction[a][b] = true; // bottom-left block\n }\n}\n\n/** Draw every function pattern and mark reserved areas. */\nexport function drawFunctionPatterns(grid: QrGrid, version: number): void {\n drawFinder(grid, 0, 0);\n drawFinder(grid, grid.size - 7, 0);\n drawFinder(grid, 0, grid.size - 7);\n drawTiming(grid);\n const positions = alignmentPatternPositions(version);\n for (const cy of positions)\n for (const cx of positions) {\n // Skip the three corners covered by finder patterns.\n const isCorner =\n (cx === 6 && cy === 6) || (cx === 6 && cy === grid.size - 7) || (cx === grid.size - 7 && cy === 6);\n if (!isCorner) drawAlignment(grid, cx, cy);\n }\n reserveFormatAreas(grid);\n reserveVersionAreas(grid, version);\n}\n\n/** Place codeword bits into non-function modules via the zigzag scan. */\nexport function placeData(grid: QrGrid, codewords: readonly number[]): void {\n const size = grid.size;\n const totalBits = codewords.length * 8;\n let bitIndex = 0;\n let upward = true;\n for (let right = size - 1; right >= 1; right -= 2) {\n if (right === 6) right = 5; // skip the vertical timing column\n for (let vert = 0; vert < size; vert++) {\n for (let j = 0; j < 2; j++) {\n const x = right - j;\n const y = upward ? size - 1 - vert : vert;\n if (grid.isFunction[y][x]) continue;\n grid.modules[y][x] = bitIndex < totalBits && ((codewords[bitIndex >>> 3] >>> (7 - (bitIndex & 7))) & 1) === 1;\n bitIndex++;\n }\n }\n upward = !upward;\n }\n}\n","/**\n * GF(2⁸) arithmetic over the QR primitive polynomial x⁸+x⁴+x³+x²+1 (0x11D).\n * Tables are built once at module load: `EXP[i] = αⁱ` for generator α = 2.\n */\n\nconst PRIMITIVE = 0x11d;\n\nconst EXP = new Uint8Array(512);\nconst LOG = new Uint8Array(256);\n\n{\n let x = 1;\n for (let i = 0; i < 255; i++) {\n EXP[i] = x;\n LOG[x] = i;\n x <<= 1;\n if (x & 0x100) x ^= PRIMITIVE;\n }\n // Duplicate the cycle so `EXP[log(a) + log(b)]` never needs a mod.\n for (let i = 255; i < 512; i++) EXP[i] = EXP[i - 255];\n}\n\n/** `a * b` in GF(256); `0` when either operand is 0. */\nexport function gfMultiply(a: number, b: number): number {\n return a === 0 || b === 0 ? 0 : EXP[LOG[a] + LOG[b]];\n}\n\n/** `αⁱ`: the i-th power of the generator. `i` may exceed 254 (wraps). */\nexport function gfExp(i: number): number {\n return EXP[i % 255];\n}\n\n/** Polynomial evaluation in GF(256): Σ coeffᵢ·xⁱ with coeff[0] highest-degree. */\nexport function gfPolyEval(coeffs: readonly number[], x: number): number {\n let y = 0;\n for (const c of coeffs) y = gfMultiply(y, x) ^ c;\n return y;\n}\n\n/** Multiply two polynomials (coefficients highest-degree first). */\nexport function gfPolyMultiply(p: readonly number[], q: readonly number[]): number[] {\n const out = new Array<number>(p.length + q.length - 1).fill(0);\n for (let i = 0; i < p.length; i++) for (let j = 0; j < q.length; j++) out[i + j] ^= gfMultiply(p[i], q[j]);\n return out;\n}\n","import { gfExp, gfMultiply, gfPolyMultiply } from './_galois';\n\n/**\n * Reed–Solomon error-correction codewords over GF(256).\n * The generator polynomial for `degree` EC codewords is ∏ᵢ₌₀..degree₋₁ (x − αⁱ);\n * results are cached per degree (max 30 per ISO Table 9).\n */\n\nconst generatorCache = new Map<number, readonly number[]>();\n\n/** Generator polynomial coefficients (highest-degree first, leading 1 kept). */\nfunction generatorPoly(degree: number): readonly number[] {\n const poly = generatorCache.get(degree);\n if (poly) return poly;\n let g = [1];\n for (let i = 0; i < degree; i++) g = gfPolyMultiply(g, [1, gfExp(i)]);\n generatorCache.set(degree, g);\n return g;\n}\n\n/** EC codewords for one data block: remainder of data·x^degree ÷ generator. */\nexport function ecCodewords(data: readonly number[], degree: number): number[] {\n const gen = generatorPoly(degree); // gen[0] === 1\n const rem = new Array<number>(degree).fill(0);\n for (const b of data) {\n const factor = b ^ rem[0];\n rem.copyWithin(0, 1);\n rem[degree - 1] = 0;\n if (factor !== 0) for (let j = 0; j < degree; j++) rem[j] ^= gfMultiply(gen[j + 1], factor);\n }\n return rem;\n}\n","import { ALPHANUMERIC_CHARSET, CHAR_COUNT_BITS, dataCodewords, MODE_BITS, versionGroup } from './_tables';\nimport type { QrErrorCorrection, QrMode } from './types';\n\n/**\n * Data-segment assembly: one segment (single mode) covering the whole input,\n * followed by terminator, byte alignment, and 0xEC/0x11 padding (§7.4–7.5).\n * Kanji and multi-segment optimization are out of scope.\n */\n\nconst textEncoder = new TextEncoder();\n\n/**\n * Payload prepared for its mode: text for numeric/alphanumeric, raw bytes for\n * byte mode. Byte mode never round-trips through a string, so invalid UTF-8\n * input survives encoding untouched.\n */\nexport type QrPayload =\n | { readonly mode: 'numeric' | 'alphanumeric'; readonly text: string }\n | { readonly mode: 'byte'; readonly bytes: Uint8Array };\n\n/** Interpret `text` as `mode`: UTF-8-encoding only for byte mode. */\nexport const payloadFromText = (text: string, mode: QrMode): QrPayload =>\n mode === 'byte' ? { bytes: textEncoder.encode(text), mode: 'byte' } : { mode, text };\n\n/** Raw binary payload; always byte mode. */\nexport const payloadFromBytes = (bytes: Uint8Array): QrPayload => ({ bytes, mode: 'byte' });\n\n/** Value carried in the character-count field. */\nexport function payloadLength(payload: QrPayload): number {\n return payload.mode === 'byte' ? payload.bytes.length : payload.text.length;\n}\n\n/** Growable bit stream; `bytes` is valid only after `padToByte()`. */\nexport class BitStream {\n private bits: number[] = [];\n\n get length(): number {\n return this.bits.length;\n }\n\n append(value: number, width: number): void {\n for (let i = width - 1; i >= 0; i--) this.bits.push((value >>> i) & 1);\n }\n\n padToByte(): void {\n while (this.bits.length % 8 !== 0) this.bits.push(0);\n }\n\n toBytes(): number[] {\n const out: number[] = [];\n for (let i = 0; i < this.bits.length; i += 8) {\n let b = 0;\n for (let j = 0; j < 8; j++) b = (b << 1) | this.bits[i + j];\n out.push(b);\n }\n return out;\n }\n}\n\n/** Most compact mode able to encode the whole text. */\nexport function detectMode(text: string): QrMode {\n if (/^\\d+$/.test(text)) return 'numeric';\n for (const ch of text) if (!ALPHANUMERIC_CHARSET.includes(ch)) return 'byte';\n return 'alphanumeric';\n}\n\n/** Payload bits for the segment body (without mode/count headers). */\nexport function dataBitLength(payload: QrPayload): number {\n switch (payload.mode) {\n case 'numeric':\n return (\n Math.floor(payload.text.length / 3) * 10 +\n (payload.text.length % 3 === 1 ? 4 : payload.text.length % 3 === 2 ? 7 : 0)\n );\n case 'alphanumeric':\n return Math.floor(payload.text.length / 2) * 11 + (payload.text.length % 2) * 6;\n case 'byte':\n return payload.bytes.length * 8;\n }\n}\n\n/** Append mode indicator, char count, and payload bits. */\nexport function appendSegment(stream: BitStream, payload: QrPayload, version: number): void {\n stream.append(MODE_BITS[payload.mode], 4);\n stream.append(payloadLength(payload), CHAR_COUNT_BITS[payload.mode][versionGroup(version)]);\n switch (payload.mode) {\n case 'numeric':\n for (let i = 0; i < payload.text.length; ) {\n const n = Math.min(3, payload.text.length - i);\n stream.append(Number.parseInt(payload.text.slice(i, i + n), 10), n === 3 ? 10 : n === 2 ? 7 : 4);\n i += n;\n }\n break;\n case 'alphanumeric':\n for (let i = 0; i < payload.text.length; ) {\n if (i + 1 < payload.text.length) {\n stream.append(\n ALPHANUMERIC_CHARSET.indexOf(payload.text[i]) * 45 + ALPHANUMERIC_CHARSET.indexOf(payload.text[i + 1]),\n 11,\n );\n i += 2;\n } else {\n stream.append(ALPHANUMERIC_CHARSET.indexOf(payload.text[i]), 6);\n i += 1;\n }\n }\n break;\n case 'byte':\n for (const b of payload.bytes) stream.append(b, 8);\n break;\n }\n}\n\n/** Capacity in bits for the data area of (version, level). */\nexport const dataCapacityBits = (version: number, level: QrErrorCorrection): number =>\n dataCodewords(version, level) * 8;\n\n/** Bits a segment occupies at `version`: header + payload, before terminator. */\nexport function segmentBits(payload: QrPayload, version: number): number {\n return 4 + CHAR_COUNT_BITS[payload.mode][versionGroup(version)] + dataBitLength(payload);\n}\n\n/**\n * Full data-codeword sequence for (version, level): segment + terminator +\n * alignment + pad bytes. Caller guarantees the segment fits.\n */\nexport function buildDataCodewords(payload: QrPayload, version: number, level: QrErrorCorrection): number[] {\n const stream = new BitStream();\n appendSegment(stream, payload, version);\n const capacity = dataCapacityBits(version, level);\n stream.append(0, Math.min(4, capacity - stream.length)); // terminator\n stream.padToByte();\n const bytes = stream.toBytes();\n const pad = [0xec, 0x11];\n for (let i = 0; bytes.length < dataCodewords(version, level); i++) bytes.push(pad[i % 2]);\n return bytes;\n}\n","import { drawFormatInfo, drawVersionInfo } from './_format';\nimport { applyMask, penaltyScore } from './_mask';\nimport { createGrid, drawFunctionPatterns, placeData } from './_matrix';\nimport { ecCodewords } from './_reed-solomon';\nimport {\n buildDataCodewords,\n detectMode,\n payloadFromBytes,\n payloadFromText,\n payloadLength,\n type QrPayload,\n segmentBits,\n} from './_segments';\nimport {\n ALPHANUMERIC_CHARSET,\n CHAR_COUNT_BITS,\n dataCodewords,\n ecCodewordsPerBlock,\n matrixSize,\n numEcBlocks,\n totalCodewords,\n versionGroup,\n} from './_tables';\nimport { SigilCapacityError, SigilOptionError } from './errors';\nimport type { QrEncodeOptions, QrErrorCorrection, QrMatrix, QrMode } from './types';\n\nconst MAX_VERSION = 40;\n\nfunction checkOptions(options: QrEncodeOptions): void {\n const { version, minVersion, mask, errorCorrection } = options;\n const inRange = (v: number) => Number.isInteger(v) && v >= 1 && v <= MAX_VERSION;\n if (version !== undefined && !inRange(version))\n throw new SigilOptionError(`version must be an integer 1–${MAX_VERSION}, got ${version}`);\n if (minVersion !== undefined && !inRange(minVersion))\n throw new SigilOptionError(`minVersion must be an integer 1–${MAX_VERSION}, got ${minVersion}`);\n if (version !== undefined && minVersion !== undefined && minVersion > version)\n throw new SigilOptionError(`minVersion (${minVersion}) exceeds version (${version})`);\n if (mask !== undefined && (!Number.isInteger(mask) || mask < 0 || mask > 7))\n throw new SigilOptionError(`mask must be an integer 0–7, got ${mask}`);\n if (errorCorrection !== undefined && !'LMQH'.includes(errorCorrection))\n throw new SigilOptionError(`errorCorrection must be 'L', 'M', 'Q', or 'H'`);\n}\n\n/** Character capacity of (version, level, mode): the `qrCapacity` core. */\nfunction capacityFor(version: number, level: QrErrorCorrection, mode: QrMode): number {\n const countBits = CHAR_COUNT_BITS[mode][versionGroup(version)];\n const usable = dataCodewords(version, level) * 8 - 4 - countBits;\n if (usable <= 0) return 0;\n switch (mode) {\n case 'numeric':\n return Math.floor(usable / 10) * 3 + (usable % 10 >= 7 ? 2 : usable % 10 >= 4 ? 1 : 0);\n case 'alphanumeric':\n return Math.floor(usable / 11) * 2 + (usable % 11 >= 6 ? 1 : 0);\n case 'byte':\n return Math.floor(usable / 8);\n }\n}\n\n/** Smallest version ≥ minVersion whose data area fits the segment, or `null`. */\nfunction pickVersion(payload: QrPayload, level: QrErrorCorrection, minVersion: number): number | null {\n for (let v = minVersion; v <= MAX_VERSION; v++) if (segmentBits(payload, v) <= dataCodewords(v, level) * 8) return v;\n return null;\n}\n\n/** The capacity error for a payload that does not fit at `version`. */\nfunction capacityError(payload: QrPayload, level: QrErrorCorrection, version: number): SigilCapacityError {\n const length = payloadLength(payload);\n const max = capacityFor(version, level, payload.mode);\n const unit = payload.mode === 'byte' ? 'bytes' : 'chars';\n return new SigilCapacityError(\n `Input of ${length} ${unit} exceeds QR capacity (${max} ${unit} at version ${version}-${level})`,\n length,\n max,\n version,\n );\n}\n\n/** Split data codewords into EC blocks and interleave data + EC (§7.6). */\nfunction interleaveBlocks(data: readonly number[], version: number, level: QrErrorCorrection): number[] {\n const numBlocks = numEcBlocks(version, level);\n const ecLen = ecCodewordsPerBlock(version, level);\n const rawLen = totalCodewords(version);\n const shortLen = Math.floor(rawLen / numBlocks) - ecLen; // data codewords in a short block\n const numLong = rawLen % numBlocks; // long blocks carry one extra data codeword\n\n const blocks: number[][] = [];\n let offset = 0;\n for (let b = 0; b < numBlocks; b++) {\n const isLong = b >= numBlocks - numLong;\n const dat = data.slice(offset, offset + shortLen + (isLong ? 1 : 0));\n offset += dat.length;\n const ecc = ecCodewords(dat, ecLen);\n // Short blocks get a pad slot so every block array shares one length;\n // the slot is skipped during interleave below.\n blocks.push(isLong ? [...dat, ...ecc] : [...dat, 0, ...ecc]);\n }\n\n const out: number[] = [];\n for (let i = 0; i < blocks[0].length; i++)\n for (let b = 0; b < numBlocks; b++) {\n // Skip the pad slot on short blocks (index = shortLen).\n if (i !== shortLen || b >= numBlocks - numLong) out.push(blocks[b][i]);\n }\n return out;\n}\n\nfunction freezeMatrix(grid: readonly (readonly boolean[])[], meta: Omit<QrMatrix, 'get'>): QrMatrix {\n const modules = grid.map((row) => Object.freeze([...row]));\n Object.freeze(modules);\n return Object.freeze({\n ...meta,\n get: (x: number, y: number) => (x >= 0 && y >= 0 && x < meta.size && y < meta.size ? modules[y][x] : false),\n });\n}\n\n/**\n * Encode `data` into a QR Model 2 symbol. Pure and synchronous.\n * Strings pick the most compact mode; `Uint8Array` is raw binary and always\n * byte mode, encoded as-is: no UTF-8 round-trip. Byte mode is UTF-8 without\n * an ECI header for string input: the industry-standard assumption.\n */\nexport function encodeQr(data: string | Uint8Array, options: QrEncodeOptions = {}): QrMatrix {\n checkOptions(options);\n if (data.length === 0) throw new SigilOptionError('Cannot encode an empty input');\n\n const level = options.errorCorrection ?? 'M';\n if (typeof data !== 'string' && options.mode !== undefined && options.mode !== 'byte')\n throw new SigilOptionError('Uint8Array input can only be encoded in byte mode');\n const mode = options.mode ?? (typeof data === 'string' ? detectMode(data) : 'byte');\n if (typeof data === 'string' && !isModeCompatible(data, mode))\n throw new SigilOptionError(`Input cannot be encoded in ${mode} mode`);\n const payload = typeof data === 'string' ? payloadFromText(data, mode) : payloadFromBytes(data);\n\n const version = options.version ?? pickVersion(payload, level, options.minVersion ?? 1);\n if (version === null || segmentBits(payload, version) > dataCodewords(version, level) * 8)\n throw capacityError(payload, level, options.version ?? MAX_VERSION);\n\n const codewords = interleaveBlocks(buildDataCodewords(payload, version, level), version, level);\n const grid = createGrid(matrixSize(version));\n drawFunctionPatterns(grid, version);\n placeData(grid, codewords);\n\n // Try every mask (or the forced one), keep the lowest penalty. Each candidate\n // is undone by the idempotent XOR, and the final drawFormatInfo below rewrites\n // every format module, so candidates never leak into each other.\n const candidates = options.mask !== undefined ? [options.mask] : [0, 1, 2, 3, 4, 5, 6, 7];\n let bestMask = candidates[0];\n let bestScore = Number.POSITIVE_INFINITY;\n for (const m of candidates) {\n applyMask(grid, m);\n drawFormatInfo(grid, level, m);\n const score = penaltyScore(grid);\n if (score < bestScore) {\n bestScore = score;\n bestMask = m;\n }\n applyMask(grid, m); // undo\n }\n\n // The grid is unmasked again: draw the winning candidate once, finally.\n applyMask(grid, bestMask);\n drawFormatInfo(grid, level, bestMask);\n drawVersionInfo(grid, version);\n\n return freezeMatrix(grid.modules, {\n errorCorrection: level,\n mask: bestMask,\n mode,\n size: grid.size,\n version,\n });\n}\n\n/** Whether `text` is representable in `mode` (used when the mode is forced). */\nfunction isModeCompatible(text: string, mode: QrMode): boolean {\n if (mode === 'numeric') return /^\\d+$/.test(text);\n if (mode === 'alphanumeric') return [...text].every((ch) => ALPHANUMERIC_CHARSET.includes(ch));\n return true;\n}\n\n/** Max characters/bytes encodable at (version, level, mode). */\nexport function qrCapacity(version: number, errorCorrection: QrErrorCorrection, mode: QrMode): number {\n if (!Number.isInteger(version) || version < 1 || version > MAX_VERSION)\n throw new SigilOptionError(`version must be an integer 1–${MAX_VERSION}, got ${version}`);\n return capacityFor(version, errorCorrection, mode);\n}\n","import { SigilDisposedError, SigilError, SigilPermissionError, SigilUnsupportedError } from './errors';\nimport type { QrDetector, QrScanner, QrScannerOptions, QrScannerStatus, QrScanResult, SigilEvent } from './types';\n\n/**\n * Scanning via the native `BarcodeDetector` API: a thin lifecycle wrapper.\n * Feature detection is lazy so importing the package is always safe (SSR).\n * No from-scratch image decoder: unsupported environments get\n * `SigilUnsupportedError` at `start()`/`detectQr()`, never at import.\n */\n\ninterface BarcodeDetectorLike {\n detect(\n source: ImageBitmapSource,\n ): Promise<ReadonlyArray<{ rawValue: string; cornerPoints?: ReadonlyArray<{ x: number; y: number }> }>>;\n}\n\ninterface BarcodeDetectorCtor {\n getSupportedFormats?(): Promise<readonly string[]>;\n new (options?: { formats?: string[] }): BarcodeDetectorLike;\n}\n\nconst globalScope = globalThis as { BarcodeDetector?: BarcodeDetectorCtor };\n\nconst barcodeDetector = (): BarcodeDetectorCtor | undefined => globalScope.BarcodeDetector;\n\n/** Sync check: `BarcodeDetector` exists. Format support needs the async variant. */\nexport function isQrScanSupported(): boolean {\n return typeof barcodeDetector() === 'function';\n}\n\n/** Full check: `BarcodeDetector` exists and reports `qr_code` support. */\nexport async function qrScanSupport(): Promise<boolean> {\n const ctor = barcodeDetector();\n if (typeof ctor !== 'function') return false;\n if (typeof ctor.getSupportedFormats !== 'function') return true;\n try {\n return (await ctor.getSupportedFormats()).includes('qr_code');\n } catch {\n return false;\n }\n}\n\n/** One-shot detection on an image source; `null` when no code is found. */\nexport async function detectQr(\n source: ImageBitmapSource,\n options: { signal?: AbortSignal; detector?: QrDetector } = {},\n): Promise<QrScanResult | null> {\n options.signal?.throwIfAborted();\n const ctor = barcodeDetector();\n const detector = options.detector ?? (ctor ? new ctor({ formats: ['qr_code'] }) : undefined);\n if (!detector) throw new SigilUnsupportedError('BarcodeDetector is not available in this environment');\n const results = await detector.detect(source);\n options.signal?.throwIfAborted();\n const first = results[0];\n return first ? { cornerPoints: first.cornerPoints, value: first.rawValue } : null;\n}\n\nexport function createQrScanner(options: QrScannerOptions): QrScanner {\n const media = options.mediaDevices ?? globalThis.navigator?.mediaDevices;\n const once = options.once ?? true;\n const intervalMs = options.intervalMs ?? 200;\n const disposal = new AbortController();\n const tappers = new Set<(event: SigilEvent) => void>();\n const handlers = new Set<(result: QrScanResult) => void>();\n\n let status: QrScannerStatus = 'idle';\n let stream: MediaStream | null = null;\n let timer: ReturnType<typeof setInterval> | null = null;\n let busy = false;\n let detector: Promise<QrDetector> | undefined;\n\n const emit = (event: SigilEvent): void => {\n if (tappers.size === 0) return;\n for (const handler of [...tappers]) {\n try {\n handler(event);\n } catch {\n // Observability must never affect behavior.\n }\n }\n };\n\n const setStatus = (next: QrScannerStatus): void => {\n if (status === next) return;\n status = next;\n emit({ status: next, type: 'status-change' });\n };\n\n // Read through a function: status changes across awaits via closures, and a\n // direct read would be narrowed to the pre-await value by the compiler.\n const isStarting = (): boolean => status === 'starting';\n\n const stopTracks = (): void => {\n if (timer !== null) {\n clearInterval(timer);\n timer = null;\n }\n if (stream) {\n for (const track of stream.getTracks()) track.stop();\n stream = null;\n }\n options.video.srcObject = null;\n };\n\n const fail = (error: SigilError): void => {\n emit({ error, type: 'error' });\n stopTracks();\n setStatus('idle');\n };\n\n // Created on first start() so a missing BarcodeDetector never rejects a\n // promise nobody awaits (construction must stay side-effect-free).\n const getDetector = (): Promise<QrDetector> => {\n detector ??= (async () => {\n if (options.detector) return options.detector;\n const ctor = barcodeDetector();\n if (typeof ctor !== 'function')\n throw new SigilUnsupportedError('BarcodeDetector is not available in this environment');\n return new ctor({ formats: ['qr_code'] });\n })();\n return detector;\n };\n\n const tick = async (): Promise<void> => {\n if (status !== 'scanning' || stream === null) return;\n const video = options.video;\n if (video.readyState < 2 /* HAVE_CURRENT_DATA */) {\n emit({ reason: 'not-ready', type: 'frame-skipped' });\n return;\n }\n if (busy) {\n emit({ reason: 'busy', type: 'frame-skipped' });\n return;\n }\n busy = true;\n const started = Date.now();\n try {\n const qrDetector = await getDetector();\n const results = await qrDetector.detect(video);\n const first = results[0];\n if (first) {\n const result: QrScanResult = { cornerPoints: first.cornerPoints, value: first.rawValue };\n emit({ elapsedMs: Date.now() - started, type: 'detect', value: result.value });\n for (const handler of [...handlers]) handler(result);\n if (once) {\n stopTracks();\n setStatus('idle');\n }\n }\n } catch (error) {\n fail(error instanceof SigilError ? error : new SigilError('QR detection failed', { cause: error }));\n } finally {\n busy = false;\n }\n };\n\n const api: QrScanner = {\n get disposalSignal() {\n return disposal.signal;\n },\n dispose() {\n if (status === 'disposed') return;\n emit({ type: 'dispose' });\n stopTracks();\n handlers.clear();\n tappers.clear();\n setStatus('disposed');\n disposal.abort();\n },\n get disposed() {\n return status === 'disposed';\n },\n onResult(handler) {\n if (status === 'disposed') return () => {};\n handlers.add(handler);\n return () => handlers.delete(handler);\n },\n async start() {\n if (status === 'disposed') throw new SigilDisposedError('Scanner is disposed');\n if (status === 'starting' || status === 'scanning') return;\n if (!media || typeof media.getUserMedia !== 'function')\n throw new SigilUnsupportedError('getUserMedia is not available in this environment');\n // Surface a missing detector at start() (not construction) per contract.\n await getDetector();\n options.signal?.throwIfAborted();\n setStatus('starting');\n let newStream: MediaStream;\n try {\n newStream = await media.getUserMedia({ video: options.constraints ?? { facingMode: 'environment' } });\n } catch (error) {\n setStatus('idle');\n if (error instanceof DOMException && error.name === 'NotAllowedError')\n throw new SigilPermissionError('Camera permission denied', { cause: error });\n throw error instanceof Error ? error : new SigilError('Camera request failed', { cause: error });\n }\n // stop()/dispose() during the permission prompt must not resurrect the scanner.\n if (!isStarting()) {\n for (const track of newStream.getTracks()) track.stop();\n return;\n }\n stream = newStream;\n options.video.srcObject = stream;\n await options.video.play().catch(() => {});\n if (!isStarting()) {\n stopTracks();\n return;\n }\n setStatus('scanning');\n timer = setInterval(() => void tick(), intervalMs);\n void tick();\n },\n get status() {\n return status;\n },\n stop() {\n if (status === 'disposed') return;\n stopTracks();\n setStatus('idle');\n },\n tap(handler, tapOptions) {\n if (status === 'disposed') return () => {};\n tappers.add(handler);\n const off = () => tappers.delete(handler);\n tapOptions?.signal?.addEventListener('abort', off, { once: true });\n return off;\n },\n [Symbol.dispose]() {\n api.dispose();\n },\n };\n\n if (options.signal) {\n const onAbort = (): void => api.stop();\n options.signal.addEventListener('abort', onAbort, { once: true });\n // A long-lived signal must not retain the scanner past dispose().\n disposal.signal.addEventListener('abort', () => options.signal?.removeEventListener('abort', onAbort), {\n once: true,\n });\n }\n return api;\n}\n","import type { QrMatrix, QrSvgOptions } from './types';\n\n/**\n * SVG rendering: pure string output, safe in any environment.\n * The optimized path merges each row's dark-module runs into `M x y hW v1 h-W z`\n * spans; `optimizePath: false` emits one subpath per module.\n */\n\nconst esc = (s: string): string =>\n s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');\n\nexport function toSvg(matrix: QrMatrix, options: QrSvgOptions = {}): string {\n const margin = options.margin ?? 4;\n const scale = options.scale ?? 1;\n const dark = options.dark ?? 'currentColor';\n const light = options.light ?? 'transparent';\n const optimize = options.optimizePath ?? true;\n const dim = (matrix.size + margin * 2) * scale;\n\n const parts: string[] = [`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${dim} ${dim}\" role=\"img\"`];\n if (options.label !== undefined) {\n parts.push(` aria-label=\"${esc(options.label)}\"`);\n }\n parts.push(` shape-rendering=\"crispEdges\">`);\n if (options.label !== undefined) parts.push(`<title>${esc(options.label)}</title>`);\n if (light !== 'transparent') parts.push(`<rect width=\"${dim}\" height=\"${dim}\" fill=\"${light}\"/>`);\n\n const path: string[] = [];\n for (let y = 0; y < matrix.size; y++) {\n let x = 0;\n while (x < matrix.size) {\n if (!matrix.get(x, y)) {\n x++;\n continue;\n }\n if (optimize) {\n let run = 1;\n while (x + run < matrix.size && matrix.get(x + run, y)) run++;\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${run * scale}v${scale}h${-run * scale}z`);\n x += run;\n } else {\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${scale}v${scale}h${-scale}z`);\n x++;\n }\n }\n }\n parts.push(`<path d=\"${path.join('')}\" fill=\"${dark}\"/>`);\n parts.push('</svg>');\n return parts.join('');\n}\n"],"mappings":"AAIA,IAAa,WAAb,cAAgC,KAAM,CACpC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,mBAAb,cAAwC,UAAW,CACjD,MACA,SACA,QAEA,YAAY,EAAiB,EAAe,EAAkB,EAAiB,EAAqB,CAClG,MAAM,EAAS,CAAI,EACnB,KAAK,MAAQ,EACb,KAAK,SAAW,EAChB,KAAK,QAAU,CACjB,CACF,EAGa,iBAAb,cAAsC,UAAW,CAAC,EAMrC,sBAAb,cAA2C,UAAW,CAAC,EAG1C,qBAAb,cAA0C,UAAW,CAAC,EAGzC,mBAAb,cAAwC,UAAW,CAAC,EC9BpD,SAAgB,aAAa,EAAkB,EAA2B,EAA2B,CAAC,EAAW,CAC/G,IAAM,EAAS,EAAQ,QAAU,EAC3B,EAAQ,EAAQ,OAAS,EACzB,EAAO,EAAQ,MAAQ,UACvB,EAAQ,EAAQ,OAA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wDAAwD,EAAI,GAAG,EAAI,aAAa,EACrG,EAAQ,QAAU,IAAA,IACpB,EAAM,KAAK,gBAAgB,IAAI,EAAQ,KAAK,EAAE,EAAE,EAElD,EAAM,KAAK,gCAAgC,EACvC,EAAQ,QAAU,IAAA,IAAW,EAAM,KAAK,UAAU,IAAI,EAAQ,KAAK,EAAE,SAAS,EAC9E,IAAU,eAAe,EAAM,KAAK,gBAAgB,EAAI,YAAY,EAAI,UAAU,EAAM,IAAI,EAEhG,IAAM,EAAiB,CAAC,EACxB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,KAAM,IAAK,CACpC,IAAI,EAAI,EACR,KAAO,EAAI,EAAO,MAAM,CACtB,GAAI,CAAC,EAAO,IAAI,EAAG,CAAC,EAAG,CACrB,IACA,QACF,CACA,GAAI,EAAU,CACZ,IAAI,EAAM,EACV,KAAO,EAAI,EAAM,EAAO,MAAQ,EAAO,IAAI,EAAI,EAAK,CAAC,GAAG,IACxD,EAAK,KAAK,KAAK,EAAI,GAAU,EAAM,IAAI,EAAI,GAAU,EAAM,GAAG,EAAM,EAAM,GAAG,EAAM,GAAG,CAAC,EAAM,EAAM,EAAE,EACrG,GAAK,CACP,MACE,EAAK,KAAK,KAAK,EAAI,GAAU,EAAM,IAAI,EAAI,GAAU,EAAM,GAAG,EAAM,GAAG,EAAM,GAAG,CAAC,EAAM,EAAE,EACzF,GAEJ,CACF,CAGA,OAFA,EAAM,KAAK,YAAY,EAAK,KAAK,EAAE,EAAE,UAAU,EAAK,IAAI,EACxD,EAAM,KAAK,QAAQ,EACZ,EAAM,KAAK,EAAE,CACtB"}
|
package/dist/svg.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.cjs","names":[],"sources":["../src/svg.ts"],"sourcesContent":["import type { QrMatrix, QrSvgOptions } from './types';\n\n/**\n * SVG rendering
|
|
1
|
+
{"version":3,"file":"svg.cjs","names":[],"sources":["../src/svg.ts"],"sourcesContent":["import type { QrMatrix, QrSvgOptions } from './types';\n\n/**\n * SVG rendering: pure string output, safe in any environment.\n * The optimized path merges each row's dark-module runs into `M x y hW v1 h-W z`\n * spans; `optimizePath: false` emits one subpath per module.\n */\n\nconst esc = (s: string): string =>\n s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');\n\nexport function toSvg(matrix: QrMatrix, options: QrSvgOptions = {}): string {\n const margin = options.margin ?? 4;\n const scale = options.scale ?? 1;\n const dark = options.dark ?? 'currentColor';\n const light = options.light ?? 'transparent';\n const optimize = options.optimizePath ?? true;\n const dim = (matrix.size + margin * 2) * scale;\n\n const parts: string[] = [`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${dim} ${dim}\" role=\"img\"`];\n if (options.label !== undefined) {\n parts.push(` aria-label=\"${esc(options.label)}\"`);\n }\n parts.push(` shape-rendering=\"crispEdges\">`);\n if (options.label !== undefined) parts.push(`<title>${esc(options.label)}</title>`);\n if (light !== 'transparent') parts.push(`<rect width=\"${dim}\" height=\"${dim}\" fill=\"${light}\"/>`);\n\n const path: string[] = [];\n for (let y = 0; y < matrix.size; y++) {\n let x = 0;\n while (x < matrix.size) {\n if (!matrix.get(x, y)) {\n x++;\n continue;\n }\n if (optimize) {\n let run = 1;\n while (x + run < matrix.size && matrix.get(x + run, y)) run++;\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${run * scale}v${scale}h${-run * scale}z`);\n x += run;\n } else {\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${scale}v${scale}h${-scale}z`);\n x++;\n }\n }\n }\n parts.push(`<path d=\"${path.join('')}\" fill=\"${dark}\"/>`);\n parts.push('</svg>');\n return parts.join('');\n}\n"],"mappings":"AAQA,IAAM,IAAO,GACX,EAAE,QAAQ,KAAM,OAAO,CAAC,CAAC,QAAQ,KAAM,MAAM,CAAC,CAAC,QAAQ,KAAM,MAAM,CAAC,CAAC,QAAQ,KAAM,QAAQ,EAE7F,SAAgB,MA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dist/svg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","names":[],"sources":["../src/svg.ts"],"sourcesContent":["import type { QrMatrix, QrSvgOptions } from './types';\n\n/**\n * SVG rendering
|
|
1
|
+
{"version":3,"file":"svg.js","names":[],"sources":["../src/svg.ts"],"sourcesContent":["import type { QrMatrix, QrSvgOptions } from './types';\n\n/**\n * SVG rendering: pure string output, safe in any environment.\n * The optimized path merges each row's dark-module runs into `M x y hW v1 h-W z`\n * spans; `optimizePath: false` emits one subpath per module.\n */\n\nconst esc = (s: string): string =>\n s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');\n\nexport function toSvg(matrix: QrMatrix, options: QrSvgOptions = {}): string {\n const margin = options.margin ?? 4;\n const scale = options.scale ?? 1;\n const dark = options.dark ?? 'currentColor';\n const light = options.light ?? 'transparent';\n const optimize = options.optimizePath ?? true;\n const dim = (matrix.size + margin * 2) * scale;\n\n const parts: string[] = [`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${dim} ${dim}\" role=\"img\"`];\n if (options.label !== undefined) {\n parts.push(` aria-label=\"${esc(options.label)}\"`);\n }\n parts.push(` shape-rendering=\"crispEdges\">`);\n if (options.label !== undefined) parts.push(`<title>${esc(options.label)}</title>`);\n if (light !== 'transparent') parts.push(`<rect width=\"${dim}\" height=\"${dim}\" fill=\"${light}\"/>`);\n\n const path: string[] = [];\n for (let y = 0; y < matrix.size; y++) {\n let x = 0;\n while (x < matrix.size) {\n if (!matrix.get(x, y)) {\n x++;\n continue;\n }\n if (optimize) {\n let run = 1;\n while (x + run < matrix.size && matrix.get(x + run, y)) run++;\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${run * scale}v${scale}h${-run * scale}z`);\n x += run;\n } else {\n path.push(`M${(x + margin) * scale} ${(y + margin) * scale}h${scale}v${scale}h${-scale}z`);\n x++;\n }\n }\n }\n parts.push(`<path d=\"${path.join('')}\"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EAAI,GAAU,EAAM,GAAG,EAAM,GAAG,EAAM,GAAG,CAAC,EAAM,EAAE,EACzF,GAEJ,CACF,CAGA,OAFA,EAAM,KAAK,YAAY,EAAK,KAAK,EAAE,EAAE,UAAU,EAAK,IAAI,EACxD,EAAM,KAAK,QAAQ,EACZ,EAAM,KAAK,EAAE,CACtB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface QrEncodeOptions {
|
|
|
18
18
|
/** An encoded QR symbol: a square matrix of dark/light modules. */
|
|
19
19
|
export interface QrMatrix {
|
|
20
20
|
readonly errorCorrection: QrErrorCorrection;
|
|
21
|
-
/** Module color at (`x`, `y`)
|
|
21
|
+
/** Module color at (`x`, `y`): `true` = dark, `false` outside bounds. */
|
|
22
22
|
get(x: number, y: number): boolean;
|
|
23
23
|
readonly mask: number;
|
|
24
24
|
readonly mode: QrMode;
|
|
@@ -54,7 +54,7 @@ export interface QrScanResult {
|
|
|
54
54
|
}>;
|
|
55
55
|
readonly value: string;
|
|
56
56
|
}
|
|
57
|
-
/** Injected QR detector
|
|
57
|
+
/** Injected QR detector: matches the native `BarcodeDetector` shape. */
|
|
58
58
|
export interface QrDetector {
|
|
59
59
|
detect(source: ImageBitmapSource): Promise<ReadonlyArray<{
|
|
60
60
|
rawValue: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEtD,mEAAmE;AACnE,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,MAAM,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,eAAe,CAAC,EA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C,EAAE,WAAW,CAAA;KAAE,GAAG,MAAM,IAAI,CAAC;IACnG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACpE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAA;CAAE,GACzE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vielzeug/sigil",
|
|
3
|
-
"version": "26.10.
|
|
4
|
-
"description": "QR code generation and scanning
|
|
3
|
+
"version": "26.10.1",
|
|
4
|
+
"description": "QR code generation and scanning: pure matrix encoder, SVG and canvas renderers, native BarcodeDetector scanning",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/helmuthdu/vielzeug",
|