quadqr-js 1.0.2 → 1.3.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.
@@ -0,0 +1,108 @@
1
+ # Triangle16 experimental data-cell profile
2
+
3
+ Triangle16 is an experimental QuadQR data-cell encoding for the high-density branch. It keeps the existing QuadQR geometry, finder patterns, timing pattern, alignment patterns, calibration, Spectrum ECC, CRC, security envelope, compression, and signing behavior, but changes how payload data cells are represented.
4
+
5
+ ## Physical cell
6
+
7
+ A Triangle16 payload cell is split by one fixed `/` diagonal:
8
+
9
+ ```text
10
+ +---------+
11
+ | AAAAAA /|
12
+ | AAAAA /B|
13
+ | AAAA /BB|
14
+ | AAA /BBB|
15
+ | AA /BBBB|
16
+ | A /BBBBB|
17
+ | /BBBBBBB|
18
+ +---------+
19
+ ```
20
+
21
+ `A` is the upper-left triangle and `B` is the lower-right triangle. Each triangle independently uses the existing RGBW alphabet:
22
+
23
+ ```text
24
+ R = 00
25
+ G = 01
26
+ B = 10
27
+ W = 11
28
+ ```
29
+
30
+ The pair therefore has 16 states:
31
+
32
+ ```text
33
+ R/R R/G R/B R/W
34
+ G/R G/G G/B G/W
35
+ B/R B/G B/B B/W
36
+ W/R W/G W/B W/W
37
+ ```
38
+
39
+ The first triangle carries the high 2 bits and the second triangle carries the low 2 bits. One Triangle16 body cell therefore carries 4 raw bits, so one byte occupies two body cells instead of four RGBW cells.
40
+
41
+ ## Protected header stays solid
42
+
43
+ The protected bootstrap/header intentionally does not use mixed-color triangles. Its normal RGBW header cells are represented as same-color pairs such as `R/R`, `G/G`, `B/B`, and `W/W`.
44
+
45
+ This uses four cells per protected header byte, exactly like RGBW, but makes it much easier for the decoder to recover the mode flag when the image is blurred, skewed, resized, or color-shifted. Header flag bit 6 declares Triangle16 for the ECC-protected body.
46
+
47
+ ## Scanner sampling
48
+
49
+ The scanner does not sample the diagonal or the exact module center. For each data cell it samples two small regions well inside the triangles, approximately around `(0.28, 0.28)` and `(0.72, 0.72)` in normalized module coordinates.
50
+
51
+ Each triangle is classified independently against the calibrated RGBW palette. The cell confidence is the weaker of the two triangle confidences. That confidence feeds the existing confidence-aware Spectrum ECC path, allowing an ambiguous triangle pair to become a useful erasure candidate instead of an arbitrary hard error.
52
+
53
+ The normal image and camera scanner automatically attempts Triangle16 sampling. No separate scan mode is required. If ordinary finder/alignment geometry is good enough to locate the symbol but not precise enough to decode the half-cell regions, the scanner performs one bounded **precise-alignment recovery** pass. That pass uses denser alignment-pattern probes and a finer sub-module search, then retries the same dual-triangle classifier.
54
+
55
+ ## Rendering rules
56
+
57
+ Triangle16 uses exact hard-edged triangular payload cells. Decorative payload styles are intentionally bypassed in this profile because rounded, inset, soft, or depth effects can reduce the usable sampling area or contaminate the diagonal boundary. Structural modules keep the normal QuadQR rendering behavior.
58
+
59
+ PNG/ImageData, Canvas, SVG, browser, and Node rendering all support Triangle16.
60
+
61
+ ## API
62
+
63
+ ```js
64
+ import { encodeText, CELL_ENCODINGS } from "quadqr-js";
65
+
66
+ const code = encodeText("High-density QuadQR", {
67
+ ecc: "M",
68
+ cellEncoding: CELL_ENCODINGS.TRIANGLE16
69
+ });
70
+ ```
71
+
72
+ The string form is also accepted:
73
+
74
+ ```js
75
+ const code = encodeText("High-density QuadQR", {
76
+ cellEncoding: "triangle16"
77
+ });
78
+ ```
79
+
80
+ `rgbw` remains the library default so existing callers are not silently moved to an experimental physical format.
81
+
82
+ ## Capacity
83
+
84
+ Raw body density is:
85
+
86
+ ```text
87
+ RGBW 4 states 2 bits/body cell
88
+ Triangle16 16 states 4 bits/body cell
89
+ ```
90
+
91
+ The protected header remains RGBW-equivalent, and ECC/CRC overhead is unchanged at the byte level, so usable payload capacity is close to but not exactly 2x for a fixed matrix version.
92
+
93
+ Use `getVersionInfo(version, { ecc, cellEncoding: "triangle16" })` or the demo capacity calculator for the exact value.
94
+
95
+ ## Reliability caveat
96
+
97
+ Triangle16 doubles raw body bits per cell, but it also halves the spatial area available to each independently classified color. Its meaningful real-world metric is not only bits per matrix cell. It is reliable payload bytes at a fixed physical size, camera distance, angle, lighting condition, resize/compression pipeline, and print quality.
98
+
99
+ The branch should therefore be stress-tested before treating Triangle16 as a stable format. Important cases include:
100
+
101
+ - perspective and partial finder degradation;
102
+ - defocus and motion blur;
103
+ - low camera pixel coverage per module;
104
+ - JPEG compression and repeated image resizing;
105
+ - shadows, glare, white-balance shifts, and saturation changes;
106
+ - cheap printing, ink spread, paper tint, and camera recapture.
107
+
108
+ If full 16-state reliability becomes the limiting factor, a restricted triangle alphabet can be explored later without changing the basic physical-cell experiment.
package/docs/WASM.md CHANGED
@@ -17,7 +17,7 @@ const state = await initWasm();
17
17
  console.log(state);
18
18
  ```
19
19
 
20
- In QuadQR 0.7.x, the WASM module accelerates CRC-32. Once initialized, normal encode/decode operations automatically use the installed accelerator.
20
+ In QuadQR 1.x, the WASM module accelerates CRC-32. Once initialized, normal encode/decode operations automatically use the installed accelerator.
21
21
 
22
22
  ## Check the current state
23
23
 
@@ -56,7 +56,7 @@ You can also provide WASM bytes directly through the `bytes` option.
56
56
  When the classic `quadqr.min.js` global build is loaded from a CDN, `QuadQR.initWasm()` resolves the bundled sibling WASM asset from the same package/version location.
57
57
 
58
58
  ```html
59
- <script src="https://cdn.jsdelivr.net/npm/quadqr-js@1.0.1/dist/quadqr.min.js"></script>
59
+ <script src="https://cdn.jsdelivr.net/npm/quadqr-js@1.1.0/dist/quadqr.min.js"></script>
60
60
  <script>
61
61
  await QuadQR.initWasm();
62
62
  </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quadqr-js",
3
- "version": "1.0.2",
4
- "description": "QuadQR: experimental four-state RGBW matrix code with Spectrum ECC, browser/Node scanning, CDN builds, and optional AES-256-GCM secure payloads.",
3
+ "version": "1.3.0",
4
+ "description": "QuadQR: experimental RGBW matrix code with optional experimental High Density Mode, Spectrum ECC, browser/Node scanning, compression, signing, diagnostics, stress testing, and AES-256-GCM security.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -44,6 +44,7 @@
44
44
  "bin",
45
45
  "docs",
46
46
  "FORMAT.md",
47
+ "SPECIFICATION.md",
47
48
  "README.md",
48
49
  "LICENSE"
49
50
  ],
@@ -81,6 +82,8 @@
81
82
  "qr",
82
83
  "rgb",
83
84
  "rgbw",
85
+ "high-density",
86
+ "triangle16",
84
87
  "matrix-code",
85
88
  "barcode",
86
89
  "reed-solomon",
@@ -89,7 +92,11 @@
89
92
  "camera-scanner",
90
93
  "encryption",
91
94
  "aes-gcm",
92
- "wasm"
95
+ "wasm",
96
+ "compression",
97
+ "ed25519",
98
+ "scan-diagnostics",
99
+ "print-qr"
93
100
  ],
94
101
  "sideEffects": false
95
102
  }
@@ -1,7 +1,8 @@
1
1
  import type { EccLevel } from "./index.js";
2
2
  export const STANDARD_QR_BYTE_CAPACITY: Readonly<Record<EccLevel, readonly number[]>>;
3
3
  export function getStandardQrByteCapacity(version: number, ecc?: EccLevel): number;
4
- export function compareCapacity(version: number, ecc?: EccLevel): Record<string, number | string>;
5
- export function buildCapacityComparison(options?: { ecc?: EccLevel; versions?: number[] }): Array<Record<string, number | string>>;
4
+ export function compareCapacity(version: number, ecc?: EccLevel, options?: { highDensity?: boolean }): Record<string, number | string | null>;
5
+ export function calculateCapacityPlan(options?: { payload?: string | Uint8Array; payloadBytes?: number; ecc?: EccLevel; highDensity?: boolean; compression?: "none" | "auto" | "lz"; signed?: boolean; keyId?: string; embedPublicKey?: boolean }): Record<string, unknown>;
6
+ export function buildCapacityComparison(options?: { ecc?: EccLevel; highDensity?: boolean; versions?: number[] }): Array<Record<string, number | string | null>>;
6
7
  export function benchmarkCodec(options?: Record<string, unknown>): Record<string, unknown>;
7
- export function benchmarkReport(options?: Record<string, unknown>): string;
8
+ export function benchmarkReport(options?: Record<string, unknown>): Record<string, unknown>;
package/types/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export type EccLevel = "L" | "M" | "Q" | "H";
2
2
  export type RenderStyle = "classic" | "depth" | "soft" | "inset";
3
+ export type RenderMode = "screen" | "print";
4
+ export type CompressionMode = "none" | "auto" | "lz";
3
5
  export type SecurityMode = "password" | "raw-key";
4
6
 
5
7
  export interface Palette {
@@ -11,12 +13,30 @@ export interface Palette {
11
13
  }
12
14
 
13
15
  export interface EncodeOptions {
14
- version?: number;
16
+ version?: number | "auto";
17
+ minVersion?: number;
18
+ maxVersion?: number;
15
19
  ecc?: EccLevel;
20
+ /** Enable the experimental High Density Mode. Default: false. Uses Triangle16 payload cells at 4 raw bits/body cell. */
21
+ highDensity?: boolean;
16
22
  maskId?: number;
17
23
  text?: boolean;
24
+ compression?: CompressionMode;
18
25
  }
19
26
 
27
+ export interface SigningOptions {
28
+ /** Private Ed25519 key used to create the signature. Never embed or distribute it. */
29
+ privateKey: CryptoKey | Uint8Array | ArrayBuffer;
30
+ /** Optional compact identifier stored with the signature so a verifier can select a trusted public key. */
31
+ keyId?: string;
32
+ /** Optional public key used only when embedPublicKey is explicitly enabled. */
33
+ publicKey?: CryptoKey | Uint8Array | ArrayBuffer;
34
+ /** Embed the public key for self-contained integrity checks. Default: false. */
35
+ embedPublicKey?: boolean;
36
+ }
37
+
38
+ export interface SignedEncodeOptions extends EncodeOptions, SigningOptions {}
39
+
20
40
  export interface PasswordSecurity {
21
41
  mode: "password";
22
42
  password: string;
@@ -32,6 +52,7 @@ export interface RawKeySecurity {
32
52
 
33
53
  export interface SecureEncodeOptions extends EncodeOptions {
34
54
  security: PasswordSecurity | RawKeySecurity;
55
+ signing?: SigningOptions;
35
56
  }
36
57
 
37
58
  export interface QuadQRCode {
@@ -40,9 +61,15 @@ export interface QuadQRCode {
40
61
  size: number;
41
62
  formatVersion: number;
42
63
  eccLevel: EccLevel;
64
+ highDensity?: boolean;
65
+ bitsPerDataCell?: 2 | 4;
66
+ statesPerDataCell?: 4 | 16;
43
67
  payloadBytes: number;
44
68
  capacityBytes: number;
45
69
  secure?: boolean;
70
+ compressed?: boolean;
71
+ compression?: "none" | "lz";
72
+ signed?: boolean;
46
73
  security?: SecurityMetadata | null;
47
74
  [key: string]: unknown;
48
75
  }
@@ -61,6 +88,22 @@ export interface SecurityMetadata {
61
88
  [key: string]: unknown;
62
89
  }
63
90
 
91
+ export interface ScanDiagnostics {
92
+ confidence: number;
93
+ cellConfidence: number;
94
+ structureConfidence: number;
95
+ geometryConfidence: number;
96
+ calibrationConfidence: number;
97
+ eccUtilization: number;
98
+ correctedErrors: number;
99
+ erasureSymbols: number;
100
+ stages?: Record<string, boolean>;
101
+ failedStage?: string | null;
102
+ geometryCandidates?: unknown[];
103
+ sampled?: Record<string, unknown> | null;
104
+ [key: string]: unknown;
105
+ }
106
+
64
107
  export interface DecodeResult {
65
108
  payload: Uint8Array;
66
109
  text: string | null;
@@ -68,11 +111,32 @@ export interface DecodeResult {
68
111
  size: number;
69
112
  formatVersion: number;
70
113
  eccLevel: EccLevel;
114
+ highDensity?: boolean;
115
+ bitsPerDataCell?: 2 | 4;
116
+ statesPerDataCell?: 4 | 16;
71
117
  secure: boolean;
72
118
  requiresDecryption?: boolean;
73
119
  decrypted?: boolean;
74
120
  security?: SecurityMetadata | null;
75
121
  encryptedPayload?: Uint8Array;
122
+ protectedPayload?: Uint8Array;
123
+ compressed?: boolean;
124
+ compression?: "none" | "lz";
125
+ signed?: boolean;
126
+ /** Legacy v1 signer label, if decoding an older signed symbol. */
127
+ signer?: string | null;
128
+ signingKeyId?: string | null;
129
+ hasEmbeddedPublicKey?: boolean;
130
+ signatureVerified?: boolean | null;
131
+ signatureTrusted?: boolean | null;
132
+ signatureTrustSource?: "external" | "embedded" | null;
133
+ confidence?: number;
134
+ geometryConfidence?: number;
135
+ calibrationConfidence?: number;
136
+ structureConfidence?: number;
137
+ correctedErrors?: number;
138
+ eccUtilization?: number;
139
+ diagnostics?: ScanDiagnostics;
76
140
  [key: string]: unknown;
77
141
  }
78
142
 
@@ -82,6 +146,21 @@ export interface ImageDataLike {
82
146
  data: Uint8ClampedArray | Uint8Array;
83
147
  }
84
148
 
149
+ export interface LogoRenderOptions {
150
+ /** Loaded CanvasImageSource in canvas rendering, ImageDataLike in pixel rendering, or URL/data URL in SVG rendering. */
151
+ source: CanvasImageSource | ImageDataLike | string;
152
+ /** Logo width/height as a fraction of the symbol area. Clamped to 0.05..0.30. Default: 0.18. */
153
+ size?: number | "auto";
154
+ /** Clear the modules behind the logo with a solid background before drawing it. */
155
+ clearBackground?: boolean;
156
+ /** Background padding around the logo in modules. Default: 0.65. */
157
+ padding?: number;
158
+ /** Rounded background corner radius in modules. Default: 0.8. */
159
+ radius?: number;
160
+ /** Background color used when clearBackground is enabled. Default: palette white. */
161
+ backgroundColor?: string;
162
+ }
163
+
85
164
  export interface CameraFinderDiagnostic {
86
165
  x: number;
87
166
  y: number;
@@ -128,14 +207,30 @@ export interface CameraDiagnosticEvent {
128
207
  }
129
208
 
130
209
  export interface RenderOptions {
210
+ /** Exact square output size in pixels. If neither imageSize nor moduleSize is supplied, defaults to 720. */
211
+ imageSize?: number;
212
+ /** Legacy/low-level pixels per module sizing. Used when imageSize is not supplied. */
131
213
  moduleSize?: number;
132
214
  quietZone?: number;
133
215
  palette?: Palette;
134
216
  style?: RenderStyle;
217
+ /** Screen defaults or print-safe palette/quiet-zone/classic-style behavior. */
218
+ mode?: RenderMode;
219
+ renderMode?: RenderMode;
220
+ allowStyledPrint?: boolean;
221
+ allowUnsafePrintQuietZone?: boolean;
222
+ logo?: CanvasImageSource | ImageDataLike | string | LogoRenderOptions;
223
+ logoSize?: number;
224
+ logoClearBackground?: boolean;
225
+ logoPadding?: number;
226
+ logoRadius?: number;
227
+ logoBackgroundColor?: string;
135
228
  [key: string]: unknown;
136
229
  }
137
230
 
138
231
  export interface ScanOptions {
232
+ debug?: boolean;
233
+ debugMatrices?: boolean;
139
234
  minVersion?: number;
140
235
  maxVersion?: number;
141
236
  perspective?: boolean;
@@ -143,12 +238,27 @@ export interface ScanOptions {
143
238
  maxDimension?: number;
144
239
  sampleRadius?: number;
145
240
  robustSampleRadius?: number;
241
+ /** Disable automatic High Density Mode dual-region sampling. Default: enabled. */
242
+ highDensitySampling?: boolean;
243
+ /** Position of the two High Density Mode samples inside each module. Default: 0.28. */
244
+ highDensitySampleInset?: number;
245
+ /** Radius used around each High Density Mode sample point. */
246
+ highDensitySampleRadius?: number;
247
+ /** Retry failed perspective scans with finer alignment localization. Default: true. */
248
+ preciseAlignmentRecovery?: boolean;
146
249
  adaptiveSampling?: boolean;
147
250
  spatialColorNormalization?: boolean;
148
251
  structureTolerance?: number;
149
252
  maxErasureConfidence?: number;
150
253
  geometryRefinement?: boolean;
151
254
  finderRecovery?: boolean;
255
+ /** Refine a valid projective solution with reliable secondary alignment markers on dense versions. */
256
+ alignmentRefinement?: boolean;
257
+ alignmentRefinePatternThreshold?: number;
258
+ alignmentRefineMaxPoints?: number;
259
+ alignmentRefineMaxDisplacement?: number;
260
+ alignmentRefineCandidateMargin?: number;
261
+ alignmentRefineSkipScore?: number;
152
262
  finderAutoColorBlackClip?: number;
153
263
  finderAutoColorWhiteClip?: number;
154
264
  finderAutoColorHighlightPercentile?: number;
@@ -213,6 +323,11 @@ export interface CameraScanOptions extends ScanOptions {
213
323
  cameraAutoColorTargetSamples?: number;
214
324
  cameraAutoEnhanceEvery?: number;
215
325
  cameraFinderRecoveryEvery?: number;
326
+ /** Retry a dense/partial geometry frame at higher resolution after at least two finders are detected. */
327
+ cameraHighResolutionRecovery?: boolean;
328
+ cameraHighResolutionMaxDimension?: number;
329
+ cameraHighResolutionEvery?: number;
330
+ cameraHighResolutionMinFinders?: number;
216
331
  constraints?: MediaStreamConstraints;
217
332
  onResult?: (result: DecodeResult, frame?: CameraFrameMeta | null) => void | Promise<void>;
218
333
  onDecode?: (result: DecodeResult, frame?: CameraFrameMeta | null) => void | Promise<void>;
@@ -224,6 +339,10 @@ export const FORMAT_VERSION: number;
224
339
  export const MIN_VERSION: number;
225
340
  export const MAX_VERSION: number;
226
341
  export const DEFAULT_ECC_LEVEL: EccLevel;
342
+ export const RENDER_MODES: Readonly<{ SCREEN: "screen"; PRINT: "print" }>;
343
+ export const PRINT_PALETTE: Readonly<Required<Palette>>;
344
+ export const COMPRESSION_MODES: Readonly<Record<string, CompressionMode>>;
345
+ export const SIGNATURE_ALGORITHMS: Readonly<{ ED25519: "Ed25519" }>;
227
346
  export const CELL: Readonly<{ BLACK: -1; RED: 0; GREEN: 1; BLUE: 2; WHITE: 3 }>;
228
347
  export const DEFAULT_PALETTE: Readonly<Required<Palette>>;
229
348
  export const RENDER_STYLES: Readonly<Record<string, RenderStyle>>;
@@ -235,19 +354,42 @@ export const DEFAULT_PBKDF2_ITERATIONS: number;
235
354
 
236
355
  export function encodeText(text: string, options?: EncodeOptions): QuadQRCode;
237
356
  export function encodeBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options?: EncodeOptions): QuadQRCode;
357
+ export function encodeUint8Array(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options?: EncodeOptions): QuadQRCode;
358
+ export function encodeSignedText(text: string, options: SignedEncodeOptions): Promise<QuadQRCode>;
359
+ export function encodeSignedBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options: SignedEncodeOptions): Promise<QuadQRCode>;
238
360
  export function encodeSecureText(text: string, options: SecureEncodeOptions): Promise<QuadQRCode>;
239
361
  export function encodeSecureBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options: SecureEncodeOptions): Promise<QuadQRCode>;
362
+ export function compressPayload(input: Uint8Array | ArrayBuffer | ArrayLike<number>): Uint8Array;
363
+ export function decompressPayload(input: Uint8Array | ArrayBuffer | ArrayLike<number>, expectedLength?: number | null): Uint8Array;
364
+ export function deriveSigningKeyId(publicKey: CryptoKey | Uint8Array | ArrayBuffer, bytes?: number): Promise<string>;
365
+ export function generateSigningKeyPair(): Promise<{ privateKey: CryptoKey; publicKey: CryptoKey; privateKeyPkcs8: Uint8Array; publicKeyBytes: Uint8Array; keyId: string; algorithm: "Ed25519" }>;
240
366
  export function decodeMatrix(matrix: number[][], options?: Record<string, unknown>): DecodeResult;
367
+ export function decodeUint8Array(matrix: number[][], options?: Record<string, unknown>): Uint8Array;
241
368
  export function decryptDecoded(result: DecodeResult, credentials: { password: string } | { key: string | Uint8Array | ArrayBuffer }): Promise<DecodeResult>;
369
+ export function verifyDecodedSignature(result: DecodeResult, options?: {
370
+ publicKey?: CryptoKey | Uint8Array | ArrayBuffer;
371
+ trustedPublicKey?: CryptoKey | Uint8Array | ArrayBuffer;
372
+ trustedKeys?: Record<string, CryptoKey | Uint8Array | ArrayBuffer> | Map<string, CryptoKey | Uint8Array | ArrayBuffer>;
373
+ allowEmbeddedKey?: boolean;
374
+ }): Promise<DecodeResult>;
242
375
  export function renderToCanvas(codeOrMatrix: QuadQRCode | number[][], canvas: HTMLCanvasElement, options?: RenderOptions): HTMLCanvasElement;
243
376
  export function renderToImageData(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions): ImageDataLike;
377
+ export function renderToSVG(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions): string;
378
+ export function estimateSafeLogoSize(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions & { ecc?: EccLevel; utilization?: number }): number;
379
+ export function findMaxSafeLogoSize(code: QuadQRCode, options: RenderOptions & { minSize?: number; maxSize?: number; iterations?: number }): { safeSize: number; testedMax: number; iterations: number; empirical: boolean };
380
+ export function getPrintGuidance(codeOrMatrix: QuadQRCode | number[][], options?: { quietZone?: number; physicalSizeMm?: number; dpi?: number; minimumModuleMm?: number }): Record<string, unknown>;
244
381
  export function scanImageData(imageData: ImageDataLike, options?: ScanOptions): DecodeResult;
382
+ export function debugScanImageData(imageData: ImageDataLike, options?: ScanOptions): { ok: boolean; result?: DecodeResult; error?: string; debug?: ScanDiagnostics | null };
245
383
  export function scanFile(file: Blob, options?: ScanOptions): Promise<DecodeResult>;
246
384
  export function scanVideoFrame(video: HTMLVideoElement, options?: ScanOptions): DecodeResult;
247
385
  export function startCameraScanner(video: HTMLVideoElement, options?: CameraScanOptions): Promise<{ stop(): void; scanNow(): DecodeResult; stream: MediaStream; video: HTMLVideoElement }>;
386
+ export function applyStressDistortion(imageData: ImageDataLike, type: string, severity?: number, options?: Record<string, unknown>): ImageDataLike;
387
+ export const STRESS_PROFILES: readonly Readonly<{ id: string; label: string; type: string; severity: number; weight: number }>[];
388
+ export function runImageStressTest(imageData: ImageDataLike, expected?: { version?: number; crc32?: number }, options?: Record<string, unknown>): Record<string, unknown>;
389
+ export function assessScanability(code: QuadQRCode, renderOptions?: RenderOptions, options?: Record<string, unknown>): Record<string, unknown>;
248
390
  export function rectifyDetectedCode(imageData: ImageDataLike, options?: Record<string, unknown>): ImageDataLike;
249
391
  export function rotateMatrix(matrix: number[][], quarterTurns?: number): number[][];
250
- export function getVersionInfo(version: number, options?: { ecc?: EccLevel }): Record<string, unknown>;
392
+ export function getVersionInfo(version: number, options?: { ecc?: EccLevel; highDensity?: boolean }): Record<string, unknown>;
251
393
  export function crc32(bytes: Uint8Array): number;
252
394
  export function installCrc32Accelerator(accelerator?: ((bytes: Uint8Array) => number) | null): void;
253
395
  export function generateRaw256Key(): Uint8Array;
package/types/node.d.ts CHANGED
@@ -5,5 +5,7 @@ export function decodePNG(input: Uint8Array | ArrayBuffer): ImageDataLike;
5
5
  export function encodePNG(imageData: ImageDataLike, options?: { compressionLevel?: number }): Buffer;
6
6
  export function toPNG(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions & { compressionLevel?: number }): Buffer;
7
7
  export function savePNG(codeOrMatrix: QuadQRCode | number[][], filename: string | URL, options?: RenderOptions & { compressionLevel?: number }): Promise<{ filename: string | URL; bytes: number }>;
8
+ export function toSVG(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions): string;
9
+ export function saveSVG(codeOrMatrix: QuadQRCode | number[][], filename: string | URL, options?: RenderOptions): Promise<{ filename: string | URL; bytes: number }>;
8
10
  export function scanBuffer(input: Uint8Array | ArrayBuffer, options?: ScanOptions): Promise<DecodeResult>;
9
11
  export function scanFile(filename: string | URL, options?: ScanOptions): Promise<DecodeResult>;