{"_id":"@canvas-components/qrcode","_rev":"5-8ef7d18f0652a785eb35ac7a2f9519f4","name":"@canvas-components/qrcode","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.1":{"name":"@canvas-components/qrcode","version":"0.1.1","license":"MIT","_id":"@canvas-components/qrcode@0.1.1","maintainers":[{"name":"anycloud666","email":"1264174856@qq.com"}],"dist":{"shasum":"220a1d1b5074607743dc62159f0e0b8c884bcc98","tarball":"https://registry.npmjs.org/@canvas-components/qrcode/-/qrcode-0.1.1.tgz","fileCount":8,"integrity":"sha512-kvrBuOC0jT07xN1Qgvccy+r6tLdoSdPxFyvpr9acrTbemcspTrxiHYuNy88HhIfraGBCge6S5pY/jA0iAAPWdQ==","signatures":[{"sig":"MEQCIHF9+9asJJDAHIJT2KI/WktUk8uMdyfiVSgYpHathRghAiBcfLfe9WcP/KRGR7XYp20xN2IL5DrnbN01FioBJd15/w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":167400},"main":"./dist/index.cjs","type":"module","_from":"file:canvas-components-qrcode-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup --config tsup.config.ts"},"_npmUser":{"name":"anycloud666","email":"1264174856@qq.com"},"_resolved":"C:\\Users\\12641\\AppData\\Local\\Temp\\dddc332e7f0147a485ff79721c91f9d8\\canvas-components-qrcode-0.1.1.tgz","_integrity":"sha512-kvrBuOC0jT07xN1Qgvccy+r6tLdoSdPxFyvpr9acrTbemcspTrxiHYuNy88HhIfraGBCge6S5pY/jA0iAAPWdQ==","_npmVersion":"10.9.0","description":"Canvas QR code drawing and export utilities.","directories":{},"sideEffects":false,"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/qrcode_0.1.1_1784608549608_0.915392415867964","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@canvas-components/qrcode","version":"0.1.2","license":"MIT","_id":"@canvas-components/qrcode@0.1.2","maintainers":[{"name":"anycloud666","email":"1264174856@qq.com"}],"dist":{"shasum":"1ccfcca5f430dbf469f087d3d80cd1bc5b76bf97","tarball":"https://registry.npmjs.org/@canvas-components/qrcode/-/qrcode-0.1.2.tgz","fileCount":8,"integrity":"sha512-DPnXN8khm3qQtIeg4FOGVyNRl/DacwvsxLi7ycgR1bWOeevCIaSovsEw3Z9hJmHN60bOPxDtEFWWwO5W4ODX0Q==","signatures":[{"sig":"MEUCIQDXvPVRTbUXuvjxp3BMdPStZ65PyIOvJSx8UV4LYv3eBQIgRQEjcSbAZjl0Pkq1i8DtZJGM0IWieyZYEKt7h2AHcpA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":167400},"main":"./dist/index.cjs","type":"module","_from":"file:canvas-components-qrcode-0.1.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup --config tsup.config.ts"},"_npmUser":{"name":"anycloud666","email":"1264174856@qq.com"},"_resolved":"C:\\Users\\12641\\AppData\\Local\\Temp\\f8e1c2fcf47c97a3f300900a6dc6de99\\canvas-components-qrcode-0.1.2.tgz","_integrity":"sha512-DPnXN8khm3qQtIeg4FOGVyNRl/DacwvsxLi7ycgR1bWOeevCIaSovsEw3Z9hJmHN60bOPxDtEFWWwO5W4ODX0Q==","_npmVersion":"10.9.0","description":"Canvas QR code drawing and export utilities.","directories":{},"sideEffects":false,"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/qrcode_0.1.2_1784617001068_0.5824580102830579","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@canvas-components/qrcode","version":"0.1.4","license":"MIT","_id":"@canvas-components/qrcode@0.1.4","maintainers":[{"name":"anycloud666","email":"1264174856@qq.com"}],"dist":{"shasum":"72fe725e7e6e183bcb46af1daa2ae406d2e0127f","tarball":"https://registry.npmjs.org/@canvas-components/qrcode/-/qrcode-0.1.4.tgz","fileCount":9,"integrity":"sha512-ctretrdsCxEYP3VSjauUrax2PfWhcY9WrFk6Zi7G4SsTf6VTyKSQlatn4Py5L92yZRI2ef+pSE4PqHPl0WrPaQ==","signatures":[{"sig":"MEUCIErgUz+ZRG0wbWTA7gi1yiufhJ/TD1iRWn0nL0igyRAQAiEAnJkM2SgH6B083vpD0lBiOsM+PP3huI1aMG4jAZerFEc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":170073},"main":"./dist/index.cjs","type":"module","_from":"file:canvas-components-qrcode-0.1.4.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup --config tsup.config.ts"},"_npmUser":{"name":"anycloud666","email":"1264174856@qq.com"},"_resolved":"C:\\Users\\12641\\AppData\\Local\\Temp\\a00a1eba0faec34bc14e5eeec75ae6d9\\canvas-components-qrcode-0.1.4.tgz","_integrity":"sha512-ctretrdsCxEYP3VSjauUrax2PfWhcY9WrFk6Zi7G4SsTf6VTyKSQlatn4Py5L92yZRI2ef+pSE4PqHPl0WrPaQ==","_npmVersion":"10.9.0","description":"Canvas QR code drawing and export utilities.","directories":{},"sideEffects":false,"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/qrcode_0.1.4_1784784672361_0.629220138117375","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@canvas-components/qrcode","version":"0.1.5","license":"MIT","_id":"@canvas-components/qrcode@0.1.5","maintainers":[{"name":"anycloud666","email":"1264174856@qq.com"}],"dist":{"shasum":"6f0fb5688f46bc7d2f5bd99e9dbfb9bcf5945d75","tarball":"https://registry.npmjs.org/@canvas-components/qrcode/-/qrcode-0.1.5.tgz","fileCount":9,"integrity":"sha512-zKqiG8j/bcJwM3cnVxz/MZL4Kt6h7VSkEXVN6svshpiKMVdcRJFhrKUdHxBEG86lLiLLyBaB70KOMpCIOj/ogA==","signatures":[{"sig":"MEUCIQDUnXALlCIwiRRWNzojchWxP0uZD0zS1FsUUrqD5FCPzAIgexxPyTSokDUwHajCkxmkLrY8v9OtXf+K80Xwxw/Q9P4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":170205},"main":"./dist/index.cjs","type":"module","_from":"file:canvas-components-qrcode-0.1.5.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18.12.0","pnpm":">=9.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup --config tsup.config.ts"},"_npmUser":{"name":"anycloud666","email":"1264174856@qq.com"},"_resolved":"C:\\Users\\12641\\AppData\\Local\\Temp\\7263672e6032a2488d68fa068f0b640c\\canvas-components-qrcode-0.1.5.tgz","_integrity":"sha512-zKqiG8j/bcJwM3cnVxz/MZL4Kt6h7VSkEXVN6svshpiKMVdcRJFhrKUdHxBEG86lLiLLyBaB70KOMpCIOj/ogA==","_npmVersion":"10.9.0","description":"Canvas QR code drawing and export utilities.","directories":{},"sideEffects":false,"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/qrcode_0.1.5_1784798132469_0.47055731071990214","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@canvas-components/qrcode","version":"0.2.0","description":"Canvas QR code drawing and export utilities.","license":"MIT","type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"publishConfig":{"access":"public"},"engines":{"node":">=18.12.0","pnpm":">=9.0.0"},"scripts":{"build":"tsup --config tsup.config.ts"},"_id":"@canvas-components/qrcode@0.2.0","_integrity":"sha512-dohFJLrMOKFoaZAcv/wgFyhqcm2ZzE/nI5BD3uRK1TPoHXEkMwakKbbsy4WE+V30ZaOReWbO/ZhDXeq3uwllig==","_resolved":"C:\\Users\\12641\\AppData\\Local\\Temp\\afe9e377f2b29288d3aeb8ee39c71aad\\canvas-components-qrcode-0.2.0.tgz","_from":"file:canvas-components-qrcode-0.2.0.tgz","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-dohFJLrMOKFoaZAcv/wgFyhqcm2ZzE/nI5BD3uRK1TPoHXEkMwakKbbsy4WE+V30ZaOReWbO/ZhDXeq3uwllig==","shasum":"8eb70d166adb6d13048a29d0708934e08f2b1302","tarball":"https://registry.npmjs.org/@canvas-components/qrcode/-/qrcode-0.2.0.tgz","fileCount":9,"unpackedSize":174445,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE4aHYBqsCywv+Y0FbdOxWl7WHco8N6OkBQQ8Gp09AKaAiEA9cLGfx1/zbdvY8C13voJCj1Mq+P3DhwnPe9TTcBUvkQ="}]},"_npmUser":{"name":"anycloud666","email":"1264174856@qq.com"},"directories":{},"maintainers":[{"name":"anycloud666","email":"1264174856@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/qrcode_0.2.0_1787135264236_0.42588811615749655"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-21T04:35:49.396Z","modified":"2026-08-19T10:27:44.531Z","0.1.1":"2026-07-21T04:35:49.726Z","0.1.2":"2026-07-21T06:56:41.220Z","0.1.4":"2026-07-23T05:31:12.501Z","0.1.5":"2026-07-23T09:15:32.639Z","0.2.0":"2026-08-19T10:27:44.390Z"},"license":"MIT","description":"Canvas QR code drawing and export utilities.","maintainers":[{"name":"anycloud666","email":"1264174856@qq.com"}],"readme":"# @canvas-components/qrcode\r\n\r\n`@canvas-components/qrcode` 是一个纯原生的 Canvas 二维码绘制与导出工具包，适合卡片、海报、票据、表格单元格和导出场景。\r\n\r\n## 功能作用\r\n\r\n- 支持二维码矩阵编码和缓存读取\r\n- 支持直接绘制到 Canvas\r\n- 支持导出为 SVG、Data URL、Blob\r\n- 支持容错等级、配色、静区、透明度配置\r\n\r\n## 安装方法\r\n\r\n```bash\r\npnpm add @canvas-components/qrcode\r\n```\r\n\r\n最低环境要求：\r\n\r\n- `Node.js >= 18.12.0`\r\n- `pnpm >= 9.0.0`\r\n\r\n## 使用方法\r\n\r\n```ts\r\nimport {\r\n  drawQrCodeToCanvas,\r\n  getQrCodeMatrix,\r\n} from \"@canvas-components/qrcode\";\r\n\r\nconst canvas = document.querySelector(\"canvas\")!;\r\nconst ctx = canvas.getContext(\"2d\")!;\r\n\r\ndrawQrCodeToCanvas({\r\n  ctx,\r\n  x: 0,\r\n  y: 0,\r\n  width: 160,\r\n  height: 160,\r\n  value: \"https://example.com\",\r\n  level: \"M\",\r\n});\r\n\r\nconst matrix = getQrCodeMatrix(\"https://example.com\", \"M\");\r\n```\r\n\r\n## 属性说明\r\n\r\n### `DrawQrCodeToCanvasOptions`\r\n\r\n| 属性 | 类型 | 说明 |\r\n| --- | --- | --- |\r\n| `ctx` | `CanvasRenderingContext2D \\| OffscreenCanvasRenderingContext2D` | 目标画布上下文 |\r\n| `x` / `y` | `number` | 绘制起点 |\r\n| `width` / `height` | `number` | 绘制区域尺寸，内部按较短边生成二维码主体 |\r\n| `value` | `string` | 编码内容 |\r\n| `level` | `\"L\" \\| \"M\" \\| \"Q\" \\| \"H\"` | 容错等级 |\r\n| `color` | `string` | 深色模块颜色 |\r\n| `backgroundColor` | `string` | 背景色 |\r\n| `padding` | `number` | 静区大小 |\r\n| `opacity` | `number` | 透明度 |\r\n\r\n### `QrCodeMatrix`\r\n\r\n| 属性 | 类型 | 说明 |\r\n| --- | --- | --- |\r\n| `version` | `number` | 二维码版本号 |\r\n| `size` | `number` | 矩阵边长 |\r\n| `modules` | `boolean[][]` | 最终深浅模块矩阵 |\r\n\r\n### `ExportQrCodeToImageOptions`\r\n\r\n| 属性 | 类型 | 说明 |\r\n| --- | --- | --- |\r\n| `pixelRatio` | `number` | 位图导出倍率 |\r\n| `type` | `\"image/png\" \\| \"image/jpeg\" \\| \"image/webp\"` | 导出类型 |\r\n| `quality` | `number` | 图片质量 |\r\n| `canvas` | `ExportCanvasLike` | 可复用外部 canvas |\r\n\r\n## 方法说明\r\n\r\n| 方法 | 签名 | 说明 |\r\n| --- | --- | --- |\r\n| `encodeQrCodeMatrix` | `(value, level?) => QrCodeMatrix` | 重新编码并返回新矩阵 |\r\n| `getQrCodeMatrix` | `(value, level?) => QrCodeMatrix` | 带缓存读取矩阵，适合重复使用 |\r\n| `drawQrCodeToCanvas` | `(options) => void` | 直接绘制到 canvas |\r\n| `exportQrCodeToSvg` | `(options) => string` | 导出 SVG 字符串 |\r\n| `exportQrCodeToDataUrl` | `(options) => Promise<string>` | 导出图片 Data URL |\r\n| `exportQrCodeToBlob` | `(options) => Promise<Blob>` | 导出图片 Blob |\r\n\r\n## 适用场景\r\n\r\n- 海报、卡片、名片二维码\r\n- 表格中的二维码单元格\r\n- 前端离屏生成下载素材\r\n- 票据、设备标识和面板角标\r\n","readmeFilename":"README.md"}