{"_id":"@amartincodes/qr-code-gen","_rev":"2-e276f1cfd0984c8cb27e733034803ecd","name":"@amartincodes/qr-code-gen","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@amartincodes/qr-code-gen","version":"1.0.0","keywords":["qr","qrcode","qr-code","qr-code-generator","png","cli"],"author":{"name":"amartincodes"},"license":"MIT","_id":"@amartincodes/qr-code-gen@1.0.0","maintainers":[{"name":"amartincodes","email":"adam.martin15@proton.me"}],"homepage":"https://github.com/amartincodes/qr_code_gen#readme","bugs":{"url":"https://github.com/amartincodes/qr_code_gen/issues"},"bin":{"qr-code-gen":"dist/cli.js"},"dist":{"shasum":"3821b7f028f85cf62822668a3b239c73353be034","tarball":"https://registry.npmjs.org/@amartincodes/qr-code-gen/-/qr-code-gen-1.0.0.tgz","fileCount":8,"integrity":"sha512-i/KAII4/cDZm7WtUjcWaJZguS1iR8ECVkYr/S3O74dwqr6chpyv2ZFElKXsLFXEEnqZKn0DFO4F7+z6Y0URAqA==","signatures":[{"sig":"MEQCIFzPlZCtNNlScnhX3wbS2jhu/nPZEAflQ9TwIMMqwHm9AiBIBu22RM3CIfw+6oiCY/1UPIXEJfRMx/qcSrJXUlP5pA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":62910},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"b8bb0131221f243f5fc36a3e3c39746593745903","scripts":{"lint":"ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts,.tsx,.js,.jsx","test":"jest --testPathIgnorePatterns=performance.test.ts","build":"npm run clean && vite build","clean":"rm -rf dist","start":"node dist/index.js","prepack":"npm run build && npm test","lint:fix":"ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts,.tsx,.js,.jsx --fix","test:all":"jest","benchmark":"tsx benchmarks/performance.benchmark.ts","test:perf":"jest performance.test.ts","benchmark:save":"tsx benchmarks/performance.benchmark.ts --save","prepublishOnly":"npm run build && npm test","pre-publish-check":"bash scripts/pre-publish-check.sh"},"_npmUser":{"name":"amartincodes","email":"adam.martin15@proton.me"},"repository":{"url":"git+https://github.com/amartincodes/qr_code_gen.git","type":"git"},"_npmVersion":"11.6.2","description":"CLI tool and library to generate QR codes in PNG format.","directories":{},"_nodeVersion":"25.1.0","dependencies":{"pngjs":"^7.0.0","encoding-japanese":"^2.2.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","jest":"^30.2.0","vite":"^7.2.2","eslint":"^9.39.1","ts-jest":"^29.4.5","prettier":"^3.6.2","typescript":"^5.9.3","@types/jest":"^30.0.0","@types/node":"^24.10.1","@types/pngjs":"^6.0.5","vite-plugin-dts":"^4.5.4","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","@types/encoding-japanese":"^2.2.1","@typescript-eslint/parser":"^8.47.0","@typescript-eslint/eslint-plugin":"^8.47.0"},"_npmOperationalInternal":{"tmp":"tmp/qr-code-gen_1.0.0_1765840240600_0.10063296409943012","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@amartincodes/qr-code-gen","version":"1.0.2","description":"CLI tool and library to generate QR codes in PNG format.","license":"MIT","author":{"name":"amartincodes"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","keywords":["qr","qrcode","qr-code","qr-code-generator","png","cli"],"repository":{"type":"git","url":"git+https://github.com/amartincodes/qr_code_gen.git"},"exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"bin":{"qr-code-gen":"dist/cli.js"},"engines":{"node":">=18.0.0"},"scripts":{"test":"jest --testPathIgnorePatterns=performance.test.ts","test:perf":"jest performance.test.ts","test:all":"jest","lint":"ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts,.tsx,.js,.jsx","lint:fix":"ESLINT_USE_FLAT_CONFIG=false eslint . --ext .ts,.tsx,.js,.jsx --fix","benchmark":"tsx benchmarks/performance.benchmark.ts","benchmark:save":"tsx benchmarks/performance.benchmark.ts --save","clean":"rm -rf dist","build":"npm run clean && vite build","prepack":"npm run build && npm test","prepublishOnly":"npm run build && npm test","pre-publish-check":"bash scripts/pre-publish-check.sh","start":"node dist/index.js"},"devDependencies":{"@types/encoding-japanese":"^2.2.1","@types/jest":"^30.0.0","@types/node":"^24.10.1","@types/pngjs":"^6.0.5","@typescript-eslint/eslint-plugin":"^8.47.0","@typescript-eslint/parser":"^8.47.0","eslint":"^9.39.1","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","jest":"^30.2.0","prettier":"^3.6.2","ts-jest":"^29.4.5","tsx":"^4.21.0","typescript":"^5.9.3","vite":"^7.2.2","vite-plugin-dts":"^4.5.4"},"dependencies":{"encoding-japanese":"^2.2.0","pngjs":"^7.0.0"},"gitHead":"37cf8872366b9306a85310c3475ccf8c8cf02ef0","_id":"@amartincodes/qr-code-gen@1.0.2","bugs":{"url":"https://github.com/amartincodes/qr_code_gen/issues"},"homepage":"https://github.com/amartincodes/qr_code_gen#readme","_nodeVersion":"25.1.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-Y4xq/FaFlQC1ImFp6NlnuH+l5ptWC/3H4Nsgy4wT9Tzlt0trjLJlY7LznLKHZODpbMr5Ffs7zstkoBESAGZ6MQ==","shasum":"6c9fbcb2d2bdecb1dfdca3fe76a102187e810426","tarball":"https://registry.npmjs.org/@amartincodes/qr-code-gen/-/qr-code-gen-1.0.2.tgz","fileCount":8,"unpackedSize":61158,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDHsk9YhB5wxRVWyPVNCEH/JZiMSxRq/eJQZLExmsFc4wIhAJPfYHzmNByOcdqx1aU+a3l0NgQQ6/WR4IYBhIsMD1TA"}]},"_npmUser":{"name":"amartincodes","email":"adam.martin15@proton.me"},"directories":{},"maintainers":[{"name":"amartincodes","email":"adam.martin15@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/qr-code-gen_1.0.2_1765841508099_0.3307143402230919"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-15T23:10:40.509Z","modified":"2025-12-15T23:31:48.496Z","1.0.0":"2025-12-15T23:10:40.789Z","1.0.2":"2025-12-15T23:31:48.280Z"},"bugs":{"url":"https://github.com/amartincodes/qr_code_gen/issues"},"author":{"name":"amartincodes"},"license":"MIT","homepage":"https://github.com/amartincodes/qr_code_gen#readme","keywords":["qr","qrcode","qr-code","qr-code-generator","png","cli"],"repository":{"type":"git","url":"git+https://github.com/amartincodes/qr_code_gen.git"},"description":"CLI tool and library to generate QR codes in PNG format.","maintainers":[{"name":"amartincodes","email":"adam.martin15@proton.me"}],"readme":"# QR Code Generator\n\nA high-performance, spec-compliant QR Code generator for Node.js with both CLI and library interfaces. Supports all QR Code versions (1-40), encoding modes, and error correction levels.\n\n[![CI](https://github.com/amartincodes/qr_code_generator/actions/workflows/ci.yaml/badge.svg)](https://github.com/amartincodes/qr_code_generator/actions/workflows/ci.yaml)\n[![Run Benchmarks](https://github.com/amartincodes/qr_code_generator/actions/workflows/benchmark.yaml/badge.svg)](https://github.com/amartincodes/qr_code_generator/actions/workflows/benchmark.yaml)\n[![npm version](https://badge.fury.io/js/@amartincodes%2Fqr-code-gen.svg)](https://www.npmjs.com/package/@amartincodes/qr-code-gen)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Node.js CI](https://img.shields.io/badge/Node.js-18.x+-green.svg)](https://nodejs.org/)\n![CLI Tool](https://img.shields.io/badge/CLI-Tool-blue.svg)\n![Library](https://img.shields.io/badge/Library-TypeScript-blue.svg)\n\n## Features\n\n- **Full QR Code Specification Support**\n  - All 40 QR Code versions (21×21 to 177×177 modules)\n  - Multiple encoding modes: Numeric, Alphanumeric, Byte, and Kanji\n  - All error correction levels: L (7%), M (15%), Q (25%), H (30%)\n\n- **High Performance**\n  - Optimized for speed with comprehensive benchmarking\n  - Efficient Reed-Solomon error correction implementation\n  - Smart encoding mode detection\n  - See [Performance Benchmarks](./PERFORMANCE.md) for detailed metrics\n\n- **Developer Friendly**\n  - Clean, well-documented API\n  - TypeScript support with full type definitions\n  - Both CLI and library interfaces\n  - Extensive test coverage\n\n- **PNG Output**\n  - Generates standard PNG images\n  - Configurable module size and quiet zone\n  - Ready for printing or digital use\n\n## Installation\n\n### As a CLI Tool\n\n```bash\nnpm install -g @amartincodes/qr-code-gen\n```\n\n### As a Library\n\n```bash\nnpm install @amartincodes/qr-code-gen\n```\n\n## Quick Start\n\n### CLI Usage\n\n```bash\n# Generate a QR code from text\nqr-code-gen \"Hello, World!\" -o qrcode.png\n\n# Generate with specific options\nqr-code-gen \"https://example.com\" \\\n  --output website.png \\\n  --version 5 \\\n  --error-correction M \\\n  --encoding BYTE\n\n# Use numeric encoding for numbers (most efficient)\nqr-code-gen \"1234567890\" --encoding NUMERIC\n```\n\n**CLI Options:**\n\n- `-o, --output <file>` - Output PNG file path (required)\n- `-v, --version <number>` - QR Code version 1-40 (default: auto-detect)\n- `-e, --error-correction <level>` - Error correction: L, M, Q, H (default: L)\n- `-m, --encoding <mode>` - Encoding mode: NUMERIC, ALPHANUMERIC, BYTE, KANJI (default: auto-detect)\n\n### Library Usage\n\n```typescript\nimport {\n  QRCodeGenerator,\n  EncodingMode,\n  ErrorCorrectionLevel\n} from \"@amartincodes/qr-code-gen\";\n\nconst generator = new QRCodeGenerator();\n\n// Simple usage - auto-detect encoding and version\nconst matrix = generator.generate(\"Hello, World!\");\n\n// Advanced usage with options\nconst matrix = generator.generate(\"https://example.com\", {\n  version: 5,\n  encodingMode: EncodingMode.BYTE,\n  errorCorrectionLevel: ErrorCorrectionLevel.M\n});\n\n// The matrix is a 2D array of 0s and 1s\n// 0 = white module, 1 = black module\nconsole.log(matrix); // [[0,0,0,...], [0,1,0,...], ...]\n```\n\n## API Reference\n\n### `QRCodeGenerator`\n\nThe main class for generating QR codes.\n\n#### `generate(data: string, options?: QRCodeOptions): number[][]`\n\nGenerates a QR code matrix from the input data.\n\n**Parameters:**\n\n- `data` (string): The data to encode in the QR code\n- `options` (optional): Configuration options\n  - `version` (1-40): QR Code version, determines size and capacity\n  - `encodingMode`: How to encode the data\n    - `EncodingMode.NUMERIC` - Digits 0-9 only (most efficient for numbers)\n    - `EncodingMode.ALPHANUMERIC` - 0-9, A-Z, space, and select symbols\n    - `EncodingMode.BYTE` - Any data (UTF-8/ISO-8859-1)\n    - `EncodingMode.KANJI` - Japanese Kanji characters\n  - `errorCorrectionLevel`: Amount of error correction\n    - `ErrorCorrectionLevel.L` - ~7% correction (smallest QR code)\n    - `ErrorCorrectionLevel.M` - ~15% correction (default)\n    - `ErrorCorrectionLevel.Q` - ~25% correction\n    - `ErrorCorrectionLevel.H` - ~30% correction (largest QR code, most resilient)\n\n**Returns:** A 2D array representing the QR code matrix (including quiet zone)\n\n**Example:**\n\n```typescript\nimport {\n  QRCodeGenerator,\n  EncodingMode,\n  ErrorCorrectionLevel\n} from \"@amartincodes/qr-code-gen\";\n\nconst generator = new QRCodeGenerator();\n\n// Auto-detect best encoding and minimal version\nconst qr1 = generator.generate(\"12345\");\n\n// Specify all options\nconst qr2 = generator.generate(\"HELLO WORLD\", {\n  version: 3,\n  encodingMode: EncodingMode.ALPHANUMERIC,\n  errorCorrectionLevel: ErrorCorrectionLevel.H\n});\n\n// Maximum capacity example (Version 40)\nconst qr3 = generator.generate(\"A\".repeat(1000), {\n  version: 40,\n  encodingMode: EncodingMode.BYTE,\n  errorCorrectionLevel: ErrorCorrectionLevel.L\n});\n```\n\n## How It Works\n\nThe QR code generation follows the official ISO/IEC 18004 specification:\n\n1. **Data Analysis** - Automatically determines the most efficient encoding mode (numeric, alphanumeric, byte, or kanji) based on input data\n2. **Data Encoding** - Converts input to a binary bit stream with mode indicator, character count, and data\n3. **Error Correction** - Generates Reed-Solomon error correction codewords using polynomial division\n4. **Structure Final Message** - Interleaves data and error correction codewords into blocks\n5. **Matrix Construction**:\n   - Creates base matrix with finder patterns (three corners)\n   - Adds separators around finder patterns\n   - Places alignment patterns (version 2+)\n   - Adds timing patterns (row 6 and column 6)\n   - Reserves areas for format and version information\n6. **Data Placement** - Places data bits in a zigzag pattern starting from bottom-right\n7. **Masking** - Applies all 8 mask patterns, evaluates each using penalty rules, selects the best\n8. **Format Information** - Adds format information (error correction level + mask pattern) with error correction\n9. **Version Information** - Adds version information for versions 7+ with error correction\n10. **Quiet Zone** - Adds 4-module quiet zone (white border) around the QR code\n\n## QR Code Capacity\n\n| Version | Size    | Numeric | Alphanumeric | Byte  | Kanji |\n| ------- | ------- | ------- | ------------ | ----- | ----- |\n| 1       | 21×21   | 41      | 25           | 17    | 10    |\n| 10      | 57×57   | 652     | 395          | 271   | 167   |\n| 20      | 97×97   | 1,901   | 1,154        | 792   | 488   |\n| 30      | 137×137 | 3,706   | 2,249        | 1,542 | 952   |\n| 40      | 177×177 | 7,089   | 4,296        | 2,953 | 1,817 |\n\n_Capacities shown are for error correction level L (7%). Higher error correction levels reduce capacity._\n\n## Performance\n\nThis library is optimized for performance. See detailed benchmarks and performance standards in:\n\n- [Performance Documentation](./PERFORMANCE.md) - Standards, optimization tips, and CI integration\n- [Benchmark Results](./benchmarks/RESULTS.md) - Historical benchmark data\n- [Benchmark Suite](./benchmarks/README.md) - Running benchmarks locally\n\n### Quick Stats (Version 10, Error Correction L)\n\n- **Generation Speed**: ~70 ops/second\n- **Average Time**: ~14ms per QR code\n- **Throughput**: 50+ codes/second for small versions\n\nRun benchmarks yourself:\n\n```bash\nnpm run benchmark        # View results only\nnpm run benchmark:save   # Save results to history\n```\n\n## Development\n\n### Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/amartincodes/qr_code_gen.git\ncd qr_code_gen\n\n# Install dependencies\nnpm install\n\n# Build the project\nnpm run build\n```\n\n### Testing\n\n```bash\n# Run all tests\nnpm test\n\n# Run only unit tests (exclude performance tests)\nnpm run test\n\n# Run performance tests\nnpm run test:perf\n\n# Run all tests including performance\nnpm run test:all\n```\n\n### Project Structure\n\n```\nqr_code_gen/\n├── src/                    # Source code\n│   ├── qrCodeGenerator.ts  # Main QR code generator\n│   ├── encoding.ts         # Data encoding logic\n│   ├── errorCorrection.ts  # Reed-Solomon error correction\n│   ├── masking.ts          # Mask pattern application\n│   ├── patterns.ts         # Finder, alignment, timing patterns\n│   └── types.ts            # TypeScript type definitions\n├── tests/                  # Test files\n│   ├── *.test.ts           # Unit tests\n│   └── performance.test.ts # Performance regression tests\n├── benchmarks/             # Performance benchmarks\n│   ├── performance.benchmark.ts\n│   ├── RESULTS.md          # Historical benchmark data\n│   └── README.md           # Benchmark documentation\n├── .github/workflows/      # CI/CD workflows\n│   ├── ci.yml              # Run tests, lint and build on push\n│   └── benchmark.yaml      # Manual benchmark workflow\n└── PERFORMANCE.md          # Performance documentation\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nPlease make sure to:\n\n- Update tests as appropriate\n- Run `npm test` to ensure all tests pass\n- Run `npm run benchmark` to check performance impact\n- Follow the existing code style\n\n## Resources\n\n- [QR Code Specification (ISO/IEC 18004)](https://www.qrcode.com/en/about/standards.html)\n- [QR Code Tutorial](https://www.thonky.com/qr-code-tutorial/)\n- [Reed-Solomon Error Correction](https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","readmeFilename":"README.md"}