qrdx 0.0.55 → 0.0.57

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.
Files changed (83) hide show
  1. package/README.md +9 -4
  2. package/dist/angular.js +1 -1
  3. package/dist/angular.mjs +1 -1
  4. package/dist/core.js +7 -7
  5. package/dist/core.js.map +1 -1
  6. package/dist/core.mjs +7 -7
  7. package/dist/core.mjs.map +1 -1
  8. package/dist/element.browser.mjs +6 -6
  9. package/dist/element.browser.mjs.map +1 -1
  10. package/dist/index.js +7 -7
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +7 -7
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/preact.js +1 -1
  15. package/dist/preact.js.map +1 -1
  16. package/dist/preact.mjs +1 -1
  17. package/dist/preact.mjs.map +1 -1
  18. package/dist/solid.js +1 -1
  19. package/dist/solid.js.map +1 -1
  20. package/dist/solid.mjs +1 -1
  21. package/dist/solid.mjs.map +1 -1
  22. package/dist/src/angular.d.mts +1 -0
  23. package/dist/src/angular.d.ts +2 -2
  24. package/dist/src/bmp.d.ts +7 -0
  25. package/dist/src/bmp.d.ts.map +1 -0
  26. package/dist/src/core.d.mts +1 -0
  27. package/dist/src/download.d.ts +12 -5
  28. package/dist/src/download.d.ts.map +1 -1
  29. package/dist/src/element-define.d.mts +1 -0
  30. package/dist/src/element.d.mts +1 -0
  31. package/dist/src/element.d.ts +1 -1
  32. package/dist/src/element.d.ts.map +1 -1
  33. package/dist/src/engine.d.ts +2 -1
  34. package/dist/src/engine.d.ts.map +1 -1
  35. package/dist/src/export.d.ts.map +1 -1
  36. package/dist/src/index.d.mts +1 -0
  37. package/dist/src/index.d.ts +1 -1
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/node.d.mts +1 -0
  40. package/dist/src/preact.d.mts +1 -0
  41. package/dist/src/preact.d.ts +5 -4
  42. package/dist/src/preact.d.ts.map +1 -1
  43. package/dist/src/qr-code-props.d.ts +19 -6
  44. package/dist/src/qr-code-props.d.ts.map +1 -1
  45. package/dist/src/qr-code.d.ts +7 -2
  46. package/dist/src/qr-code.d.ts.map +1 -1
  47. package/dist/src/scan-score.d.ts.map +1 -1
  48. package/dist/src/solid.d.mts +1 -0
  49. package/dist/src/solid.d.ts +5 -4
  50. package/dist/src/solid.d.ts.map +1 -1
  51. package/dist/src/utils/bmp.d.ts +18 -0
  52. package/dist/src/utils/bmp.d.ts.map +1 -0
  53. package/dist/src/vanilla-api.d.ts +2 -2
  54. package/dist/src/vanilla-api.d.ts.map +1 -1
  55. package/dist/src/vanilla.d.mts +1 -0
  56. package/dist/src/vue.d.mts +1 -0
  57. package/dist/src/vue.d.ts +2 -2
  58. package/dist/src/vue.d.ts.map +1 -1
  59. package/dist/types/public.d.mts +1 -0
  60. package/dist/types/public.d.ts +1 -1
  61. package/dist/types/public.d.ts.map +1 -1
  62. package/dist/types/react.d.ts +6 -0
  63. package/dist/types/react.d.ts.map +1 -1
  64. package/dist/vanilla.browser.mjs +27 -27
  65. package/dist/vanilla.browser.mjs.map +1 -1
  66. package/package.json +49 -15
  67. package/src/angular.ts +2 -2
  68. package/src/bmp.ts +25 -0
  69. package/src/download.tsx +40 -5
  70. package/src/element.ts +1 -1
  71. package/src/engine.ts +2 -0
  72. package/src/export.ts +6 -0
  73. package/src/index.tsx +5 -1
  74. package/src/preact.ts +5 -4
  75. package/src/qr-code-props.ts +77 -6
  76. package/src/qr-code.tsx +8 -6
  77. package/src/scan-score.ts +40 -32
  78. package/src/solid.ts +5 -4
  79. package/src/utils/bmp.ts +126 -0
  80. package/src/vanilla-api.ts +2 -2
  81. package/src/vue.ts +2 -2
  82. package/types/public.ts +1 -1
  83. package/types/react.ts +6 -0
package/README.md CHANGED
@@ -96,7 +96,7 @@ import { QRCode } from "qrdx";
96
96
  <QRCode value="https://example.com" size={256} logo="https://example.com/logo.png" level="H" />;
97
97
  ```
98
98
 
99
- It accepts the `QRCodeSVG` styling props above (`value`, `size`, `level`, colors, patterns, `margin`, `templateId`, `customTemplate`, `customProps`, `style`) plus:
99
+ It accepts the `QRCodeSVG` styling props above (`value`, `size`, `level`, colors, patterns, `margin`, `templateId`, `customTemplate`, `customProps`, `style`), forwards any other prop (`className`, `aria-label`, `role`, `data-*`…) to the root `<svg>` like `QRCodeSVG`, and adds:
100
100
 
101
101
  | Prop | Type | Default | Description |
102
102
  |------|------|---------|-------------|
@@ -144,7 +144,7 @@ const qr = createQRCode("#qr", {
144
144
 
145
145
  qr.update({ fgColor: "#1d4ed8" }); // merges, redraws only when the markup changes
146
146
  qr.toSVGString(); // the SVG markup
147
- await qr.toDataURL("png", { size: 1024 }); // "png", "jpg", "webp", "svg", "pdf" or "eps"
147
+ await qr.toDataURL("png", { size: 1024 }); // "png", "jpg", "webp", "bmp", "svg", "pdf" or "eps"
148
148
  await qr.download({ format: "svg", filename: "menu.svg" });
149
149
  qr.destroy(); // removes the <svg>
150
150
  ```
@@ -252,7 +252,7 @@ qr.frame = { style: "banner-bottom", text: "Scan me" };
252
252
  qr.props = { margin: 2 }; // every option at once; attributes and named properties win over it
253
253
 
254
254
  qr.toSVGString(); // the SVG markup
255
- await qr.toDataURL("png", { size: 1024 }); // "png", "jpg", "webp", "svg", "pdf" or "eps"
255
+ await qr.toDataURL("png", { size: 1024 }); // "png", "jpg", "webp", "bmp", "svg", "pdf" or "eps"
256
256
  await qr.download({ format: "svg", filename: "menu.svg" });
257
257
  ```
258
258
 
@@ -546,6 +546,7 @@ Art only renders dark dots on a light background: the background must be at leas
546
546
  import {
547
547
  copyQRCodeToClipboard,
548
548
  downloadQRCode,
549
+ getQRAsBMP,
549
550
  getQRAsWebP,
550
551
  getQRCodeDataUrl,
551
552
  getSVGString,
@@ -554,9 +555,11 @@ import {
554
555
 
555
556
  const props = { value: "https://example.com", bodyPattern: "rounded" as const };
556
557
 
557
- await downloadQRCode(props, { format: "png", size: PRESET_SIZES.large }); // png | jpg | webp | svg | pdf | eps
558
+ await downloadQRCode(props, { format: "png", size: PRESET_SIZES.large }); // png | jpg | webp | bmp | svg | pdf | eps
558
559
  await downloadQRCode(props, { format: "webp", size: PRESET_SIZES.large }); // lossless WebP
560
+ await downloadQRCode(props, { format: "bmp", size: PRESET_SIZES.large }); // 24-bit BMP, transparent areas white
559
561
  const webp = await getQRAsWebP({ ...props, size: 1024 }); // a Blob; { quality: 0.9 } makes it lossy
562
+ const bmp = await getQRAsBMP({ ...props, size: 1024 }); // a Blob of type image/bmp
560
563
  const png = await getQRAsPNG({ ...props, size: 1024 }); // PNG bytes, plain Node — import from "qrdx/node"
561
564
  await downloadQRCode(props, { format: "pdf", size: { width: 1200, height: 1200 }, filename: "qr.pdf" });
562
565
  const dataUrl = await getQRCodeDataUrl(props, "svg", { width: 512, height: 512 });
@@ -578,6 +581,8 @@ Logos are conservative by default, since a library function that runs on servers
578
581
 
579
582
  WebP is lossless by default, so module edges stay exact, and a transparent background stays transparent. `quality` (0 to 1, in `downloadQRCode` options or `getQRAsWebP`) asks for a smaller lossy file instead. The browser's canvas encodes it where it can; where it can't (Safari hands back a PNG for `image/webp`), QRdx encodes the pixels itself with a small built-in lossless encoder, so a `.webp` file is always WebP. `canvasToWebP(canvas)` does the same for any canvas, and `encodeWebPLossless(rgba, width, height)` encodes raw RGBA pixels without a DOM. Lower-level helpers: `getQRAsSVGDataUri(props)` and `getQRAsCanvas(props, mimeType, returnCanvas?)`.
580
583
 
584
+ BMP is an uncompressed 24-bit bitmap, for the legacy systems and embedded tools that only take it. No browser can encode BMP from a canvas, so QRdx writes the file itself (`canvasToBMP`, `encodeBMP`), and `isBMPFile` checks a file's header. 24-bit BMP has no alpha channel, so a transparent background comes out white.
585
+
581
586
  Vector output writes coordinates with at most 3 decimals (0.001 px in SVG, 0.001 pt in PDF and EPS; scale factors keep 6), so edges move by at most 0.0005 px and SVG markup is roughly 30% smaller than with full-precision numbers.
582
587
 
583
588
  ### Print-ready files
package/dist/angular.js CHANGED
@@ -195,7 +195,7 @@ var QRCode = class _QRCode {
195
195
  get svg() {
196
196
  return this.element;
197
197
  }
198
- /** The code as a data URL: "png" (default), "jpg", "webp", "svg", "pdf" or "eps" */
198
+ /** The code as a data URL: "png" (default), "jpg", "webp", "bmp", "svg", "pdf" or "eps" */
199
199
  toDataURL(format = "png", options = {}) {
200
200
  const current = this.options();
201
201
  return core_js.getQRCodeDataUrl(current, format, exportSize(current, options), {
package/dist/angular.mjs CHANGED
@@ -175,7 +175,7 @@ var QRCode = class _QRCode {
175
175
  get svg() {
176
176
  return this.element;
177
177
  }
178
- /** The code as a data URL: "png" (default), "jpg", "webp", "svg", "pdf" or "eps" */
178
+ /** The code as a data URL: "png" (default), "jpg", "webp", "bmp", "svg", "pdf" or "eps" */
179
179
  toDataURL(format = "png", options = {}) {
180
180
  const current = this.options();
181
181
  return getQRCodeDataUrl(current, format, exportSize(current, options), {