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.
- package/README.md +9 -4
- package/dist/angular.js +1 -1
- package/dist/angular.mjs +1 -1
- package/dist/core.js +7 -7
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +7 -7
- package/dist/core.mjs.map +1 -1
- package/dist/element.browser.mjs +6 -6
- package/dist/element.browser.mjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/dist/preact.js +1 -1
- package/dist/preact.js.map +1 -1
- package/dist/preact.mjs +1 -1
- package/dist/preact.mjs.map +1 -1
- package/dist/solid.js +1 -1
- package/dist/solid.js.map +1 -1
- package/dist/solid.mjs +1 -1
- package/dist/solid.mjs.map +1 -1
- package/dist/src/angular.d.mts +1 -0
- package/dist/src/angular.d.ts +2 -2
- package/dist/src/bmp.d.ts +7 -0
- package/dist/src/bmp.d.ts.map +1 -0
- package/dist/src/core.d.mts +1 -0
- package/dist/src/download.d.ts +12 -5
- package/dist/src/download.d.ts.map +1 -1
- package/dist/src/element-define.d.mts +1 -0
- package/dist/src/element.d.mts +1 -0
- package/dist/src/element.d.ts +1 -1
- package/dist/src/element.d.ts.map +1 -1
- package/dist/src/engine.d.ts +2 -1
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/index.d.mts +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/node.d.mts +1 -0
- package/dist/src/preact.d.mts +1 -0
- package/dist/src/preact.d.ts +5 -4
- package/dist/src/preact.d.ts.map +1 -1
- package/dist/src/qr-code-props.d.ts +19 -6
- package/dist/src/qr-code-props.d.ts.map +1 -1
- package/dist/src/qr-code.d.ts +7 -2
- package/dist/src/qr-code.d.ts.map +1 -1
- package/dist/src/scan-score.d.ts.map +1 -1
- package/dist/src/solid.d.mts +1 -0
- package/dist/src/solid.d.ts +5 -4
- package/dist/src/solid.d.ts.map +1 -1
- package/dist/src/utils/bmp.d.ts +18 -0
- package/dist/src/utils/bmp.d.ts.map +1 -0
- package/dist/src/vanilla-api.d.ts +2 -2
- package/dist/src/vanilla-api.d.ts.map +1 -1
- package/dist/src/vanilla.d.mts +1 -0
- package/dist/src/vue.d.mts +1 -0
- package/dist/src/vue.d.ts +2 -2
- package/dist/src/vue.d.ts.map +1 -1
- package/dist/types/public.d.mts +1 -0
- package/dist/types/public.d.ts +1 -1
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/react.d.ts +6 -0
- package/dist/types/react.d.ts.map +1 -1
- package/dist/vanilla.browser.mjs +27 -27
- package/dist/vanilla.browser.mjs.map +1 -1
- package/package.json +49 -15
- package/src/angular.ts +2 -2
- package/src/bmp.ts +25 -0
- package/src/download.tsx +40 -5
- package/src/element.ts +1 -1
- package/src/engine.ts +2 -0
- package/src/export.ts +6 -0
- package/src/index.tsx +5 -1
- package/src/preact.ts +5 -4
- package/src/qr-code-props.ts +77 -6
- package/src/qr-code.tsx +8 -6
- package/src/scan-score.ts +40 -32
- package/src/solid.ts +5 -4
- package/src/utils/bmp.ts +126 -0
- package/src/vanilla-api.ts +2 -2
- package/src/vue.ts +2 -2
- package/types/public.ts +1 -1
- 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`)
|
|
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), {
|