diff --git a/qrcodegen/src/main/ets/components/qrcodegen.ets b/qrcodegen/src/main/ets/components/qrcodegen.ets index 5790017d5e6d94c9efd533e503ad18c33204c5c9..7e457650d667f346039b536c08601acaabd5f8df 100644 --- a/qrcodegen/src/main/ets/components/qrcodegen.ets +++ b/qrcodegen/src/main/ets/components/qrcodegen.ets @@ -26,9 +26,9 @@ namespace qrcodegen { - type bit = number; + type bit = number; type byte = number; - type int = number; + type int = number; /*---- QR Code symbol class ----*/ @@ -96,19 +96,19 @@ namespace qrcodegen { // Find the minimal version number to use let version: int; let dataUsedBits: int; - for (version = minVersion; ; version++) { - const dataCapacityBits: int = QrCode.getNumDataCodewords(version, ecl) * 8; // Number of data bits available + for (version = minVersion;; version++) { + const dataCapacityBits: int = QrCode.getNumDataCodewords(version, ecl) * 8; // Number of data bits available const usedBits: number = QrSegment.getTotalBits(segs, version); if (usedBits <= dataCapacityBits) { dataUsedBits = usedBits; - break; // This version number is found to be suitable + break; // This version number is found to be suitable } - if (version >= maxVersion) // All versions in the range could not fit the given data + if (version >= maxVersion) // All versions in the range could not fit the given data throw "Data too long"; } // Increase the error correction level while the data still fits in the current version number - for (const newEcl of [QrCode.Ecc.MEDIUM, QrCode.Ecc.QUARTILE, QrCode.Ecc.HIGH]) { // From low to high + for (const newEcl of [QrCode.Ecc.MEDIUM, QrCode.Ecc.QUARTILE, QrCode.Ecc.HIGH]) { // From low to high if (boostEcl && dataUsedBits <= QrCode.getNumDataCodewords(version, newEcl) * 8) ecl = newEcl; } @@ -157,7 +157,7 @@ namespace qrcodegen { // The modules of this QR Code (false = white, true = black). // Immutable after constructor finishes. Accessed through getModule(). - private readonly modules : Array> = []; + private readonly modules: Array> = []; // Indicates function modules that are not subjected to masking. Discarded when constructor finishes. private readonly isFunction: Array> = []; @@ -170,8 +170,8 @@ namespace qrcodegen { // This is a low-level API that most users should not use directly. // A mid-level API is the encodeSegments() function. public constructor( - // The version number of this QR Code, which is between 1 and 40 (inclusive). - // This determines the size of this barcode. + // The version number of this QR Code, which is between 1 and 40 (inclusive). + // This determines the size of this barcode. public readonly version: int, // The error correction level used in this QR Code. @@ -196,7 +196,7 @@ namespace qrcodegen { for (let i = 0; i < this.size; i++) row.push(false); for (let i = 0; i < this.size; i++) { - this.modules .push(row.slice()); // Initially all white + this.modules.push(row.slice()); // Initially all white this.isFunction.push(row.slice()); } @@ -206,7 +206,7 @@ namespace qrcodegen { this.drawCodewords(allCodewords); // Do masking - if (mask == -1) { // Automatically choose best mask + if (mask == -1) { // Automatically choose best mask let minPenalty: int = 1000000000; for (let i = 0; i < 8; i++) { this.applyMask(i); @@ -216,14 +216,14 @@ namespace qrcodegen { mask = i; minPenalty = penalty; } - this.applyMask(i); // Undoes the mask due to XOR + this.applyMask(i); // Undoes the mask due to XOR } } if (mask < 0 || mask > 7) throw "Assertion error"; this.mask = mask; - this.applyMask(mask); // Apply the final choice of mask - this.drawFormatBits(mask); // Overwrite old format bits + this.applyMask(mask); // Apply the final choice of mask + this.drawFormatBits(mask); // Overwrite old format bits this.isFunction = []; } @@ -249,7 +249,7 @@ namespace qrcodegen { if (scale <= 0 || border < 0) throw "Value out of range"; const width: int = (this.size + border * 2) * scale; - let canvasWidth = Math.min(canvas.width+canvas.height) + let canvasWidth = Math.min(canvas.width + canvas.height) for (let y = -border; y < this.size + border; y++) { for (let x = -border; x < this.size + border; x++) { canvas.fillStyle = this.getModule(x, y) ? "#000000" : "#FFFFFF"; @@ -272,12 +272,12 @@ namespace qrcodegen { } } return ` - - - - - -` + + + + + + ` } @@ -308,7 +308,7 @@ namespace qrcodegen { } // Draw configuration data - this.drawFormatBits(0); // Dummy mask value; overwritten later in the constructor + this.drawFormatBits(0); // Dummy mask value; overwritten later in the constructor this.drawVersion(); } @@ -317,11 +317,11 @@ namespace qrcodegen { // based on the given mask and this object's error correction level field. private drawFormatBits(mask: int): void { // Calculate error correction code and pack bits - const data: int = this.errorCorrectionLevel.formatBits << 3 | mask; // errCorrLvl is uint2, mask is uint3 + const data: int = this.errorCorrectionLevel.formatBits << 3 | mask; // errCorrLvl is uint2, mask is uint3 let rem: int = data; for (let i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >>> 9) * 0x537); - const bits = (data << 10 | rem) ^ 0x5412; // uint15 + const bits = (data << 10 | rem) ^ 0x5412; // uint15 if (bits >>> 15 != 0) throw "Assertion error"; @@ -339,7 +339,7 @@ namespace qrcodegen { this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i)); for (let i = 8; i < 15; i++) this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i)); - this.setFunctionModule(8, this.size - 8, true); // Always black + this.setFunctionModule(8, this.size - 8, true); // Always black } @@ -350,10 +350,10 @@ namespace qrcodegen { return; // Calculate error correction code and pack bits - let rem: int = this.version; // version is uint6, in the range [7, 40] + let rem: int = this.version; // version is uint6, in the range [7, 40] for (let i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >>> 11) * 0x1F25); - const bits: int = this.version << 12 | rem; // uint18 + const bits: int = this.version << 12 | rem; // uint18 if (bits >>> 18 != 0) throw "Assertion error"; @@ -373,7 +373,7 @@ namespace qrcodegen { private drawFinderPattern(x: int, y: int): void { for (let dy = -4; dy <= 4; dy++) { for (let dx = -4; dx <= 4; dx++) { - const dist: int = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm + const dist: int = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm const xx: int = x + dx; const yy: int = y + dy; if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size) @@ -450,16 +450,16 @@ namespace qrcodegen { private drawCodewords(data: Array): void { if (data.length != Math.floor(QrCode.getNumRawDataModules(this.version) / 8)) throw "Invalid argument"; - let i: int = 0; // Bit index into the data + let i: int = 0; // Bit index into the data // Do the funny zigzag scan - for (let right = this.size - 1; right >= 1; right -= 2) { // Index of right column in each column pair + for (let right = this.size - 1; right >= 1; right -= 2) { // Index of right column in each column pair if (right == 6) right = 5; - for (let vert = 0; vert < this.size; vert++) { // Vertical counter + for (let vert = 0; vert < this.size; vert++) { // Vertical counter for (let j = 0; j < 2; j++) { - const x: int = right - j; // Actual x coordinate + const x: int = right - j; // Actual x coordinate const upward: boolean = ((right + 1) & 2) == 0; - const y: int = upward ? this.size - 1 - vert : vert; // Actual y coordinate + const y: int = upward ? this.size - 1 - vert : vert; // Actual y coordinate if (!this.isFunction[y][x] && i < data.length * 8) { this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7)); i++; @@ -486,15 +486,32 @@ namespace qrcodegen { for (let x = 0; x < this.size; x++) { let invert: boolean; switch (mask) { - case 0: invert = (x + y) % 2 == 0; break; - case 1: invert = y % 2 == 0; break; - case 2: invert = x % 3 == 0; break; - case 3: invert = (x + y) % 3 == 0; break; - case 4: invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0; break; - case 5: invert = x * y % 2 + x * y % 3 == 0; break; - case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; - case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; - default: throw "Assertion error"; + case 0: + invert = (x + y) % 2 == 0; + break; + case 1: + invert = y % 2 == 0; + break; + case 2: + invert = x % 3 == 0; + break; + case 3: + invert = (x + y) % 3 == 0; + break; + case 4: + invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0; + break; + case 5: + invert = x * y % 2 + x * y % 3 == 0; + break; + case 6: + invert = (x * y % 2 + x * y % 3) % 2 == 0; + break; + case 7: + invert = ((x + y) % 2 + x * y % 3) % 2 == 0; + break; + default: + throw "Assertion error"; } if (!this.isFunction[y][x] && invert) this.modules[y][x] = !this.modules[y][x]; @@ -512,7 +529,7 @@ namespace qrcodegen { for (let y = 0; y < this.size; y++) { let runColor = false; let runX = 0; - let runHistory = [0,0,0,0,0,0,0]; + let runHistory = [0, 0, 0, 0, 0, 0, 0]; for (let x = 0; x < this.size; x++) { if (this.modules[y][x] == runColor) { runX++; @@ -534,7 +551,7 @@ namespace qrcodegen { for (let x = 0; x < this.size; x++) { let runColor = false; let runY = 0; - let runHistory = [0,0,0,0,0,0,0]; + let runHistory = [0, 0, 0, 0, 0, 0, 0]; for (let y = 0; y < this.size; y++) { if (this.modules[y][x] == runColor) { runY++; @@ -557,7 +574,7 @@ namespace qrcodegen { for (let y = 0; y < this.size - 1; y++) { for (let x = 0; x < this.size - 1; x++) { const color: boolean = this.modules[y][x]; - if ( color == this.modules[y][x + 1] && + if (color == this.modules[y][x + 1] && color == this.modules[y + 1][x] && color == this.modules[y + 1][x + 1]) result += QrCode.PENALTY_N2; @@ -568,7 +585,7 @@ namespace qrcodegen { let black: int = 0; for (const row of this.modules) black = row.reduce((sum, color) => sum + (color ? 1 : 0), black); - const total: int = this.size * this.size; // Note that size is odd, so black/total != 1/2 + const total: int = this.size * this.size; // Note that size is odd, so black/total != 1/2 // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)% const k: int = Math.ceil(Math.abs(black * 20 - total * 10) / total) - 1; result += k * QrCode.PENALTY_N4; @@ -587,7 +604,7 @@ namespace qrcodegen { else { const numAlign: int = Math.floor(this.version / 7) + 2; const step: int = (this.version == 32) ? 26 : - Math.ceil((this.size - 13) / (numAlign*2 - 2)) * 2; + Math.ceil((this.size - 13) / (numAlign * 2 - 2)) * 2; let result: Array = [6]; for (let pos = this.size - 7; result.length < numAlign; pos -= step) result.splice(1, 0, pos); @@ -635,7 +652,7 @@ namespace qrcodegen { let result: Array = []; for (let i = 0; i < degree - 1; i++) result.push(0); - result.push(1); // Start off with the monomial x^0 + result.push(1); // Start off with the monomial x^0 // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), // and drop the highest monomial term which is always 1x^degree. @@ -657,7 +674,7 @@ namespace qrcodegen { // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials. private static reedSolomonComputeRemainder(data: Array, divisor: Array): Array { let result: Array = divisor.map(_ => 0); - for (const b of data) { // Polynomial division + for (const b of data) { // Polynomial division const factor: byte = b ^ (result.shift() as byte); result.push(0); divisor.forEach((coef, i) => @@ -698,11 +715,11 @@ namespace qrcodegen { // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore(). private finderPenaltyTerminateAndCount(currentRunColor: boolean, currentRunLength: int, runHistory: Array): int { - if (currentRunColor) { // Terminate black run + if (currentRunColor) { // Terminate black run this.finderPenaltyAddHistory(currentRunLength, runHistory); currentRunLength = 0; } - currentRunLength += this.size; // Add white border to final run + currentRunLength += this.size; // Add white border to final run this.finderPenaltyAddHistory(currentRunLength, runHistory); return this.finderPenaltyCountPatterns(runHistory); } @@ -711,7 +728,7 @@ namespace qrcodegen { // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore(). private finderPenaltyAddHistory(currentRunLength: int, runHistory: Array): void { if (runHistory[0] == 0) - currentRunLength += this.size; // Add white border to initial run + currentRunLength += this.size; // Add white border to initial run runHistory.pop(); runHistory.unshift(currentRunLength); } @@ -720,34 +737,31 @@ namespace qrcodegen { /*-- Constants and tables --*/ // The minimum version number supported in the QR Code Model 2 standard. - public static readonly MIN_VERSION: int = 1; + public static readonly MIN_VERSION: int = 1; // The maximum version number supported in the QR Code Model 2 standard. public static readonly MAX_VERSION: int = 40; // For use in getPenaltyScore(), when evaluating which mask is best. - private static readonly PENALTY_N1: int = 3; - private static readonly PENALTY_N2: int = 3; + private static readonly PENALTY_N1: int = 3; + private static readonly PENALTY_N2: int = 3; private static readonly PENALTY_N3: int = 40; private static readonly PENALTY_N4: int = 10; - private static readonly ECC_CODEWORDS_PER_BLOCK: Array> = [ // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level - [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Low - [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], // Medium - [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Quartile - [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // High + [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Low + [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], // Medium + [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Quartile + [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // High ]; - private static readonly NUM_ERROR_CORRECTION_BLOCKS: Array> = [ // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level - [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], // Low - [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49], // Medium - [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68], // Quartile - [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81], // High + [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], // Low + [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49], // Medium + [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68], // Quartile + [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81], // High ]; - } @@ -756,7 +770,7 @@ namespace qrcodegen { function appendBits(val: int, len: int, bb: Array): void { if (len < 0 || len > 31 || val >>> len != 0) throw "Value out of range"; - for (let i = len - 1; i >= 0; i--) // Append bit by bit + for (let i = len - 1; i >= 0; i--) // Append bit by bit bb.push((val >>> i) & 1); } @@ -767,7 +781,6 @@ namespace qrcodegen { } - /*---- Data segment class ----*/ /* @@ -801,7 +814,7 @@ namespace qrcodegen { if (!this.NUMERIC_REGEX.test(digits)) throw "String contains non-numeric characters"; let bb: Array = [] - for (let i = 0; i < digits.length; ) { // Consume up to 3 digits per iteration + for (let i = 0; i < digits.length; ) { // Consume up to 3 digits per iteration const n: int = Math.min(digits.length - i, 3); appendBits(parseInt(digits.substr(i, n), 10), n * 3 + 1, bb); i += n; @@ -818,12 +831,12 @@ namespace qrcodegen { throw "String contains unencodable characters in alphanumeric mode"; let bb: Array = [] let i: int; - for (i = 0; i + 2 <= text.length; i += 2) { // Process groups of 2 + for (i = 0; i + 2 <= text.length; i += 2) { // Process groups of 2 let temp: int = QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45; temp += QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1)); appendBits(temp, 11, bb); } - if (i < text.length) // 1 character remaining + if (i < text.length) // 1 character remaining appendBits(QrSegment.ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb); return new QrSegment(QrSegment.Mode.ALPHANUMERIC, text.length, bb); } @@ -870,7 +883,7 @@ namespace qrcodegen { // The character count (numChars) must agree with the mode and the bit buffer length, // but the constraint isn't checked. The given bit buffer is cloned and stored. public constructor( - // The mode indicator of this segment. + // The mode indicator of this segment. public readonly mode: QrSegment.Mode, // The length of this segment's unencoded data. Measured in characters for @@ -883,7 +896,7 @@ namespace qrcodegen { if (numChars < 0) throw "Invalid argument"; - this.bitData = bitData.slice(); // Make defensive copy + this.bitData = bitData.slice(); // Make defensive copy } @@ -891,7 +904,7 @@ namespace qrcodegen { // Returns a new copy of the data bits of this segment. public getData(): Array { - return this.bitData.slice(); // Make defensive copy + return this.bitData.slice(); // Make defensive copy } @@ -902,7 +915,7 @@ namespace qrcodegen { for (const seg of segs) { const ccbits: int = seg.mode.numCharCountBits(version); if (seg.numChars >= (1 << ccbits)) - return Infinity; // The segment's length doesn't fit the field's bit width + return Infinity; // The segment's length doesn't fit the field's bit width result += 4 + ccbits + seg.bitData.length; } return result; @@ -941,13 +954,11 @@ namespace qrcodegen { // The set of all legal characters in alphanumeric mode, // where each character value maps to the index in the string. private static readonly ALPHANUMERIC_CHARSET: string = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; - } } - /*---- Public helper enumeration ----*/ namespace qrcodegen.QrCode { @@ -962,25 +973,24 @@ namespace qrcodegen.QrCode { /*-- Constants --*/ - public static readonly LOW = new Ecc(0, 1); // The QR Code can tolerate about 7% erroneous codewords - public static readonly MEDIUM = new Ecc(1, 0); // The QR Code can tolerate about 15% erroneous codewords - public static readonly QUARTILE = new Ecc(2, 3); // The QR Code can tolerate about 25% erroneous codewords - public static readonly HIGH = new Ecc(3, 2); // The QR Code can tolerate about 30% erroneous codewords + public static readonly LOW = new Ecc(0, 1); // The QR Code can tolerate about 7% erroneous codewords + public static readonly MEDIUM = new Ecc(1, 0); // The QR Code can tolerate about 15% erroneous codewords + public static readonly QUARTILE = new Ecc(2, 3); // The QR Code can tolerate about 25% erroneous codewords + public static readonly HIGH = new Ecc(3, 2); // The QR Code can tolerate about 30% erroneous codewords /*-- Constructor and fields --*/ private constructor( - // In the range 0 to 3 (unsigned 2-bit integer). + // In the range 0 to 3 (unsigned 2-bit integer). public readonly ordinal: int, // (Package-private) In the range 0 to 3 (unsigned 2-bit integer). - public readonly formatBits: int) {} - + public readonly formatBits: int) { + } } } - /*---- Public helper enumeration ----*/ namespace qrcodegen.QrSegment { @@ -995,20 +1005,21 @@ namespace qrcodegen.QrSegment { /*-- Constants --*/ - public static readonly NUMERIC = new Mode(0x1, [10, 12, 14]); - public static readonly ALPHANUMERIC = new Mode(0x2, [ 9, 11, 13]); - public static readonly BYTE = new Mode(0x4, [ 8, 16, 16]); - public static readonly KANJI = new Mode(0x8, [ 8, 10, 12]); - public static readonly ECI = new Mode(0x7, [ 0, 0, 0]); + public static readonly NUMERIC = new Mode(0x1, [10, 12, 14]); + public static readonly ALPHANUMERIC = new Mode(0x2, [9, 11, 13]); + public static readonly BYTE = new Mode(0x4, [8, 16, 16]); + public static readonly KANJI = new Mode(0x8, [8, 10, 12]); + public static readonly ECI = new Mode(0x7, [0, 0, 0]); /*-- Constructor and fields --*/ private constructor( - // The mode indicator bits, which is a uint4 value (range 0 to 15). + // The mode indicator bits, which is a uint4 value (range 0 to 15). public readonly modeBits: int, // Number of character count bits for three different version ranges. - private readonly numBitsCharCount: [int,int,int]) {} + private readonly numBitsCharCount: [int, int, int]) { + } /*-- Method --*/ @@ -1018,7 +1029,7 @@ namespace qrcodegen.QrSegment { public numCharCountBits(ver: int): int { return this.numBitsCharCount[Math.floor((ver + 7) / 17)]; } - } } + export default qrcodegen \ No newline at end of file