{"id":43912786,"url":"https://github.com/veaba/qrcodes","last_synced_at":"2026-04-01T18:48:04.097Z","repository":{"id":104582239,"uuid":"552657777","full_name":"veaba/qrcodes","owner":"veaba","description":"High-performance QR code generation library with multi-runtime support (WASM, Node.js, Bun, Rust). Built for speed and flexibility.","archived":false,"fork":false,"pushed_at":"2026-02-06T22:04:51.000Z","size":1566,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-07T05:12:07.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://qrcodes.veaba.me","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/veaba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-10-17T02:46:49.000Z","updated_at":"2026-02-06T22:12:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"e017d97b-f31d-47a8-aeb9-1652f80a7f29","html_url":"https://github.com/veaba/qrcodes","commit_stats":null,"previous_names":["veaba/qrcodes"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/veaba/qrcodes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Fqrcodes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Fqrcodes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Fqrcodes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Fqrcodes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veaba","download_url":"https://codeload.github.com/veaba/qrcodes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veaba%2Fqrcodes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29400512,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-06T21:03:15.533Z","updated_at":"2026-02-13T13:13:46.882Z","avatar_url":"https://github.com/veaba.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @veaba/qrcodes\n\n\u003e 🚀 高性能 QRCode 生成器 - 支持 Rust、WASM、Node.js、Bun 的多运行时解决方案\n\u003e\n\u003e 🔥 **比主流 Rust QRCode 库快 8-75 倍！**\n\n[![Rust](https://img.shields.io/badge/Rust-1.70%2B-orange.svg)](https://www.rust-lang.org/)\n[![WASM](https://img.shields.io/badge/WebAssembly-✓-654ff0.svg)](https://webassembly.org/)\n[![Node.js](https://img.shields.io/badge/Node.js-20%2B-339933.svg)](https://nodejs.org/)\n[![Bun](https://img.shields.io/badge/Bun-1.3%2B-000000.svg)](https://bun.sh/)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n## ✨ 特性\n\n- **🦀 Rust 原生核心** - 内存安全，极致性能\n- **🔥 极致性能** - 比 crates.io 最流行的 QRCode 库快 **8-75 倍**！\n- **⚡ 多运行时支持** - 浏览器(WASM)、Node.js、Bun、原生 Rust\n- **📦 智能缓存** - 内置 LRU 缓存，重复文本生成性能提升 10-100 倍\n- **🎨 丰富样式** - 圆角、渐变、Logo 区域、多种主题风格（微信、抖音、支付宝等）\n- **🖼️ 多种输出** - SVG、PNG、Canvas、像素数据\n- **📊 完整基准测试** - 前端/后端性能对比，可视化报告\n- **🔧 TypeScript** - 完整的类型定义，优秀的开发体验\n\n## 📦 包概览\n\n| 包名 | 环境 | 特点 | 适用场景 |\n|------|------|------|----------|\n| `@veaba/qrcode-fast` | Rust | 极致性能，比 kennytm 快 **37-75 倍** | 追求极致性能的 Rust 项目 |\n| `@veaba/qrcode-rust` | Rust | 功能完整，比 kennytm 快 **8-10 倍** | 标准 Rust 项目 |\n| `@veaba/qrcode-wasm` | 浏览器 | Rust 编译为 WASM，性能最佳 | 前端生产环境 |\n| `@veaba/qrcode-js` | 浏览器 | 纯 JavaScript，即时启动 | 无需 WASM 的场景 |\n| `@veaba/qrcode-node` | Node.js | 服务端渲染，支持 PNG | Node.js 后端 |\n| `@veaba/qrcode-bun` | Bun | Bun 运行时优化 | 边缘计算、高并发 |\n| `@veaba/qrcode-js-shared` | 通用 | 共享核心，缓存系统 | 内部依赖 |\n\n## 🚀 快速开始\n\n### 安装\n\n```bash\n# 浏览器 (WASM)\npnpm add @veaba/qrcode-wasm\n\n# 浏览器 (纯 JS)\npnpm add @veaba/qrcode-js\n\n# Node.js\npnpm add @veaba/qrcode-node\n\n# Bun\npnpm add @veaba/qrcode-bun\n```\n\n### 浏览器 (WASM)\n\n```typescript\nimport init, { QRCodeCore, QRErrorCorrectLevel } from '@veaba/qrcode-wasm';\n\n// 初始化 WASM\nawait init();\n\n// 创建 QRCode\nconst qr = new QRCodeCore('https://github.com/veaba/qrcodes', QRErrorCorrectLevel.H);\nconst svg = qr.toSVG(256);\nconsole.log(svg);\n```\n\n### 浏览器 (纯 JS)\n\n```typescript\nimport { QRCodeCore, QRErrorCorrectLevel } from '@veaba/qrcode-js';\n\nconst qr = new QRCodeCore('https://github.com/veaba/qrcodes', QRErrorCorrectLevel.H);\nconst svg = qr.toSVG(256);\n```\n\n### Node.js\n\n```typescript\nimport { QRCode, QRErrorCorrectLevel } from '@veaba/qrcode-node';\n\nconst qr = new QRCode('https://github.com/veaba/qrcodes', QRErrorCorrectLevel.H);\nconst svg = qr.toSVG();\nconst png = qr.toPNGBuffer(); // 获取 PNG Buffer\n```\n\n### Bun\n\n```typescript\nimport { QRCode, QRErrorCorrectLevel } from '@veaba/qrcode-bun';\n\nconst qr = new QRCode('https://github.com/veaba/qrcodes', QRErrorCorrectLevel.H);\nconst svg = qr.toSVG();\nawait qr.saveToFile('qrcode.svg'); // Bun 文件操作\n```\n\n### Rust\n\n```rust\nuse qrcode_fast::{QRCode, QRErrorCorrectLevel};\n\n// 极致性能版本\nlet mut qr = QRCode::with_options(QRErrorCorrectLevel::H);\nqr.make_code(\"https://github.com/veaba/qrcodes\");\nlet svg = qr.get_svg();\n```\n\n## 🎨 样式化二维码\n\n```typescript\nimport { \n  generateRoundedQRCode,\n  generateGradientQRCode,\n  generateWechatStyleQRCode,\n  generateDouyinStyleQRCode,\n  generateAlipayStyleQRCode,\n  generateCyberpunkStyleQRCode \n} from '@veaba/qrcode-js'; // 或 @veaba/qrcode-wasm\n\n// 圆角二维码\nconst rounded = generateRoundedQRCode('Hello', 256, 8);\n\n// 渐变二维码\nconst gradient = generateGradientQRCode('Hello', 256, '#667eea', '#764ba2');\n\n// 微信风格\nconst wechat = generateWechatStyleQRCode('https://weixin.qq.com', 256);\n\n// 抖音风格\nconst douyin = generateDouyinStyleQRCode('https://douyin.com', 256);\n\n// 赛博朋克风格\nconst cyberpunk = generateCyberpunkStyleQRCode('Hello', 256);\n```\n\n### 支持的样式\n\n| 样式 | 函数名 | 特点 |\n|------|--------|------|\n| 圆角 | `generateRoundedQRCode` | 柔和圆角设计 |\n| Logo区域 | `generateQRCodeWithLogoArea` | 中间留白可放Logo |\n| 渐变 | `generateGradientQRCode` | 双色渐变效果 |\n| 微信 | `generateWechatStyleQRCode` | 绿色主题 #07C160 |\n| 抖音 | `generateDouyinStyleQRCode` | 黑底青红渐变 |\n| 支付宝 | `generateAlipayStyleQRCode` | 蓝色主题 + Logo区 |\n| 小红书 | `generateXiaohongshuStyleQRCode` | 红色主题 |\n| 赛博朋克 | `generateCyberpunkStyleQRCode` | 霓虹紫青渐变 |\n| 复古 | `generateRetroStyleQRCode` | Sepia 棕色调 |\n| 极简 | `generateMinimalStyleQRCode` | 细边框大圆角 |\n\n## 📊 性能基准测试\n\n### 🔥 与主流 Rust QRCode 库对比\n\n与 [kennytm/qrcode](https://github.com/kennytm/qrcode-rust) (crates.io 下载量最高的 QRCode 库) 的性能对比：\n\n#### @veaba/qrcode-fast（极致性能版）\n\n| 测试项 | @veaba/qrcode-fast | kennytm-qrcode | 速度提升 |\n|--------|-------------------|----------------|----------|\n| **单条生成** | ~18.4 µs | ~688.9 µs | **🔥 37x 更快** |\n| **SVG 生成 (Simple)** | ~10.8 µs | ~815.8 µs | **🔥 75x 更快** |\n| **SVG 生成 (Complex)** | ~18.4 µs | ~688.9 µs | **🔥 37x 更快** |\n| **纠错级别 H** | ~21.1 µs | ~446.2 µs | **🔥 21x 更快** |\n\n#### @veaba/qrcode-rust（功能完整版）\n\n| 测试项 | @veaba/qrcode-rust | kennytm-qrcode | 速度提升 |\n|--------|-------------------|----------------|----------|\n| **单条生成** | ~51.0 µs | ~438.3 µs | **🔥 8.6x 更快** |\n| **批量 100 条** | ~4.01 ms | ~32.13 ms | **🔥 8.0x 更快** |\n| **纠错级别 L** | ~29.0 µs | ~306.5 µs | **🔥 10.6x 更快** |\n| **纠错级别 H** | ~42.0 µs | ~446.2 µs | **🔥 10.6x 更快** |\n\n### 运行时性能对比\n\n| 运行时 | 单条生成 (ops/s) | SVG 输出 (ops/s) | 特点 |\n|--------|-----------------|-----------------|------|\n| 🦀 Rust (qrcode-fast) | **54,283** | **92,486** | 极致性能 |\n| 🦀 Rust (qrcode-rust) | 21,635 | 28,780 | 功能完整 |\n| 🥟 Bun | 18,902 | 18,003 | 启动快，批量优 |\n| 🟢 Node.js | 12,078 | 10,150 | 生态丰富 |\n| 🌐 WASM (浏览器) | ~15,000 | ~15,000 | 前端最快 |\n\n### 运行基准测试\n\n```bash\n# 运行所有基准测试\npnpm run benchmark\n\n# 后端测试\npnpm run benchmark:backend\npnpm run benchmark:node\npnpm run benchmark:bun\npnpm run benchmark:rust\n\n# SVG 生成测试\npnpm run bench:svg:rust:quick\npnpm run bench:svg:quick\n```\n\n## 🏗️ 项目结构\n\n```\nqrcodes/\n├── packages/\n│   ├── qrcode-fast/        # 极致性能 Rust 实现\n│   ├── qrcode-rust/        # 功能完整 Rust 实现\n│   ├── qrcode-wasm/        # Rust WASM 浏览器包\n│   ├── qrcode-js/          # 纯 JavaScript 浏览器包\n│   ├── qrcode-node/        # Node.js 后端包\n│   ├── qrcode-bun/         # Bun 后端包\n│   └── qrcode-js-shared/      # 共享核心逻辑\n├── docs/                   # Rspress 文档站点\n├── bench/                  # 基准测试工具\n│   ├── rust-tools/         # Rust 对比测试工具\n│   ├── frontend-benchmark/ # 前端性能测试\n│   └── backend-benchmark/ # 后端 PK 测试\n├── scripts/                # 构建和发布脚本\n└── skills/                 # 开发技能文档\n```\n\n## 🔧 开发\n\n### 环境要求\n\n- Windows / Linux / macOS\n- Node.js v20.19+\n- Bun 1.3.0+\n- pnpm 9.15.4+\n- Rust 1.70+\n- wasm-pack (WASM 构建)\n\n### 安装依赖\n\n```bash\npnpm install\n```\n\n### 构建所有包\n\n```bash\npnpm run build\n```\n\n### 运行测试\n\n本项目使用 **Vitest** 进行测试，支持两种测试模式：\n\n#### 单元测试 (Node.js 环境)\n\n```bash\n# 运行所有单元测试（Node.js 环境）\npnpm run test:unit\n\n# 监视模式\npnpm run test:watch\n\n# 覆盖率报告\npnpm run test:coverage\n```\n\n#### 浏览器模式测试\n\n用于测试 **WASM 模块**在真实浏览器环境中的功能，需要系统安装 Chrome：\n\n```bash\n# 运行浏览器模式测试（真实 Chrome 环境）\npnpm run test:browser\n\n# 调试模式（ headed 模式，显示浏览器窗口）\npnpm run test:browser:ui\n```\n\n**浏览器测试配置：**\n\n- 使用 Playwright 驱动真实 Chrome 浏览器\n- 自动加载并初始化 WASM 模块\n- 测试 WASM QRCode 生成、样式渲染、缓存系统等完整功能\n- 配置文件：`vitest.config.browser.ts`\n- 测试文件：`tests/**/*.browser.test.ts`\n\n#### Rust 测试\n\n```bash\n# qrcode-rust 测试\ncd packages/qrcode-rust \u0026\u0026 cargo test\n\n# qrcode-fast 测试\ncd packages/qrcode-fast \u0026\u0026 cargo test\n```\n\n#### 测试结构\n\n```\ntests/\n├── qrcode-js/           # @veaba/qrcode-js 测试\n├── qrcode-node/         # @veaba/qrcode-node 测试\n├── qrcode-js-shared/       # @veaba/qrcode-js-shared 测试\n├── qrcode-bun/          # @veaba/qrcode-bun 测试\n├── qrcode-wasm/\n│   ├── index.test.ts         # WASM API 单元测试\n│   └── index.browser.test.ts # WASM 浏览器模式测试 ⭐\n└── qrcode-wasm/pkg.test.ts   # WASM 构建产物测试\n```\n\n### 文档开发\n\n```bash\n# 启动文档开发服务器\npnpm run docs:dev\n\n# 构建文档\npnpm run docs:build\n\n# 预览文档\npnpm run docs:preview\n```\n\n## 📖 文档\n\n- [API 参考](./docs/api/index.md) - 完整 API 文档\n- [快速开始](./docs/guide/qrcode-wasm.md) - WASM 包使用指南\n- [Node.js 指南](./docs/guide/qrcode-node.md) - Node.js 包使用指南\n- [Bun 指南](./docs/guide/qrcode-bun.md) - Bun 包使用指南\n- [Rust 指南](./docs/guide/qrcode-rust.md) - Rust 包使用指南\n- [性能优化指南](./docs/guide/performance.md) - 性能优化建议\n- [基准测试指南](./skills/BENCHMARK.md) - 基准测试开发指南\n\n## 🛠️ 技术栈\n\n- **Rust** - 高性能核心算法\n- **WebAssembly** - 浏览器原生性能\n- **TypeScript** - 类型安全的 JavaScript\n- **Rspress** - 文档站点生成器\n- **Vitest** - 单元测试框架\n- **Playwright** - 浏览器测试\n- **pnpm** - 包管理器\n\n## 📄 许可证\n\n[MIT](LICENSE) © 2024-2025 veaba\n\n## 🤝 贡献\n\n欢迎 Issue 和 PR！\n\n- 🐙 GitHub: \u003chttps://github.com/veaba/qrcodes/issues\u003e\n\n---\n\n\u003e 用 ❤️ 和 🦀 Rust 构建\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveaba%2Fqrcodes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveaba%2Fqrcodes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveaba%2Fqrcodes/lists"}