qr-code-styling-node 1.7.0 → 1.8.0

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.
@@ -81,9 +81,47 @@ export interface ResvgConstructor {
81
81
  }): {
82
82
  render(): {
83
83
  asPng(): Uint8Array;
84
+ pixels: Uint8Array;
85
+ width: number;
86
+ height: number;
84
87
  };
85
88
  };
86
89
  }
90
+ export type ArtMode = "halftone" | "colorize";
91
+ export interface ArtOptions {
92
+ /** The picture to blend into the QR code (URL or data URL). */
93
+ image: string;
94
+ /**
95
+ * "halftone": the picture is redrawn as fine black/white (or colored) pixels, with the QR modules in the middle.
96
+ * "colorize": the dots keep their shape and are painted with a darkened copy of the picture.
97
+ */
98
+ mode?: ArtMode;
99
+ /** halftone only: use the picture's own colors instead of dotsOptions/backgroundOptions colors. */
100
+ colored?: boolean;
101
+ /** colorize only: also show a light copy of the picture behind the dots. Default true. */
102
+ background?: boolean;
103
+ /** 0 to 1. Higher keeps dark and light further apart: easier to scan, less of the picture. Default 0.5 (halftone), 0.7 (colorize). */
104
+ contrast?: number;
105
+ crossOrigin?: string;
106
+ }
107
+ /** Same signature as jsQR: (rgba, width, height) => { data } | null. */
108
+ export type QRDecoder = (data: Uint8ClampedArray, width: number, height: number, options?: Record<string, unknown>) => {
109
+ data: string;
110
+ } | null;
111
+ export interface VerifyOptions {
112
+ /** A QR decoder, for example `jsQR` from the "jsqr" package. */
113
+ decoder: QRDecoder;
114
+ /** For QR art: raise art.contrast step by step until the code scans. Default false. */
115
+ adjust?: boolean;
116
+ }
117
+ export interface VerifyResult {
118
+ readable: boolean;
119
+ /** Text the decoder read, if any. */
120
+ decoded?: string;
121
+ /** Final art.contrast when art is used. */
122
+ contrast?: number;
123
+ attempts: number;
124
+ }
87
125
  export type Options = {
88
126
  type?: DrawType;
89
127
  width?: number;
@@ -98,6 +136,8 @@ export type Options = {
98
136
  * node-canvas: the QR code is drawn as SVG and rasterized by resvg.
99
137
  */
100
138
  resvg?: ResvgConstructor;
139
+ /** Blend a picture into the QR code. Needs a canvas (browser, or nodeCanvas on Node). */
140
+ art?: ArtOptions;
101
141
  qrOptions?: {
102
142
  typeNumber?: TypeNumber;
103
143
  mode?: Mode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qr-code-styling-node",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Style your QR codes: dots, corners, gradients and a logo. Works in the browser and on Node.js.",
5
5
  "keywords": [
6
6
  "qr",
@@ -70,7 +70,8 @@
70
70
  "test:watch": "vitest",
71
71
  "start": "webpack serve --open --config webpack.config.dev-server.js",
72
72
  "clean": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\"",
73
- "bench": "npm run build && node scripts/bench.mjs"
73
+ "bench": "npm run build && node scripts/bench.mjs",
74
+ "art-examples": "npm run build && node scripts/art-examples.mjs"
74
75
  },
75
76
  "dependencies": {
76
77
  "qrcode-generator": "^1.4.3"
@@ -88,6 +89,7 @@
88
89
  "globals": "^15.15.0",
89
90
  "html-webpack-plugin": "^5.6.8",
90
91
  "jsdom": "^26.1.0",
92
+ "jsqr": "^1.4.0",
91
93
  "prettier": "^3.10.1",
92
94
  "qr-code-styling-node-v1-5": "npm:qr-code-styling-node@1.5.0",
93
95
  "ts-loader": "^9.6.2",