quadqr-js 1.2.0 → 1.4.2

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,64 @@
1
+ # Reliability Lab
2
+
3
+ QuadQR includes a deterministic Reliability Lab for regression testing generated symbols against camera-style damage. It is intended for comparing scanner changes, render settings, ECC profiles, output size, and the experimental High Density Mode under repeatable conditions.
4
+
5
+ The lab verifies the decoded payload CRC. Finding three locators is not counted as success unless the final payload is recovered correctly.
6
+
7
+ ## Browser demo
8
+
9
+ Open the **Reliability Lab** tab after generating a QuadQR. The lab provides:
10
+
11
+ - Quick, Full, and Extreme suites;
12
+ - per-scenario pass/fail, confidence, Reed-Solomon correction count, and decode time;
13
+ - category-level scoring for optics, lighting, color, resampling, sensor damage, and perspective;
14
+ - a 3D perspective playground with X pitch, Y yaw, and Z rotation controls;
15
+ - angle sweeps to find the largest tested pitch, yaw, or Z rotation that still decodes.
16
+
17
+ X pitch and Y yaw simulate a code plane tilting in depth. Z rotation is an in-plane rotation. The controls can be combined.
18
+
19
+ ## Public API
20
+
21
+ ```js
22
+ import {
23
+ applyStressDistortion,
24
+ runReliabilityLab,
25
+ runPerspectiveSweep
26
+ } from "quadqr-js";
27
+
28
+ const transformed = applyStressDistortion(imageData, "perspective-3d", 0.5, {
29
+ pitchDegrees: 20,
30
+ yawDegrees: 45,
31
+ rollDegrees: 15
32
+ });
33
+
34
+ const report = runReliabilityLab(imageData, {
35
+ version: encoded.version,
36
+ crc32: encoded.crc32
37
+ }, {
38
+ suite: "full"
39
+ });
40
+
41
+ const sweep = runPerspectiveSweep(imageData, {
42
+ version: encoded.version,
43
+ crc32: encoded.crc32
44
+ }, {
45
+ axis: "yaw",
46
+ angles: [0, 15, 25, 35, 45, 55]
47
+ });
48
+ ```
49
+
50
+ ## Suites
51
+
52
+ The Reliability Lab extends the smaller scanability suite with deterministic cases for lens blur, motion blur, low/high exposure, gradient shadow, glare, warm/cool color casts, contrast loss, sensor noise, JPEG-like damage, downscaling, projective skew, 3D pitch/yaw, Z rotation, and combined 3D tilt.
53
+
54
+ The **Extreme** suite adds stronger perspective cases. These are deliberately demanding and may fail at low pixels-per-module even when the same angle succeeds at a larger rendered size.
55
+
56
+ ## Perspective scanner recovery
57
+
58
+ The scanner keeps its normal fast path for ordinary frames. When locator scale differences indicate projective foreshortening, the geometry stage can perform a bounded coarse-to-fine search for the primary alignment reference. The fine stage uses denser sub-cell scoring so payload cells are less likely to impersonate the alignment marker. This improves steep-angle recovery without weakening normal structure checks globally.
59
+
60
+ Distributed secondary alignment references are still used to validate the resulting homography.
61
+
62
+ ## Interpreting results
63
+
64
+ Synthetic results are regression aids, not a substitute for real phone-camera and print testing. A useful practical metric is the largest reliable angle at the intended physical size and scanning distance, not only the theoretical bits per cell.
@@ -0,0 +1,98 @@
1
+ # Triangle16 internals for High Density Mode
2
+
3
+ Triangle16 is the experimental physical cell layout used internally by QuadQR **High Density Mode**. 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. Each triangle uses three protected interior sample anchors, robust aggregation, and a spatial-stability score. The weaker/less stable region lowers the cell confidence and supplies the first alternate state for Spectrum ECC 2.0 soft recovery.
50
+
51
+ 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.
52
+
53
+ ## Rendering rules
54
+
55
+ 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.
56
+
57
+ PNG/ImageData, Canvas, SVG, browser, and Node rendering all support Triangle16.
58
+
59
+ ## API
60
+
61
+ ```js
62
+ import { encodeText } from "quadqr-js";
63
+
64
+ const code = encodeText("High-density QuadQR", {
65
+ ecc: "M",
66
+ highDensity: true
67
+ });
68
+ ```
69
+
70
+ High Density Mode is disabled by default. `Triangle16` is an internal/technical name for the current experimental physical layout, not a separate public mode selector.
71
+
72
+ ## Capacity
73
+
74
+ Raw body density is:
75
+
76
+ ```text
77
+ RGBW 4 states 2 bits/body cell
78
+ Triangle16 16 states 4 bits/body cell
79
+ ```
80
+
81
+ 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.
82
+
83
+ Use `getVersionInfo(version, { ecc, highDensity: true })` or the demo capacity calculator for the exact value.
84
+
85
+ ## Reliability caveat
86
+
87
+ 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.
88
+
89
+ The branch should therefore be stress-tested before treating Triangle16 as a stable format. Important cases include:
90
+
91
+ - perspective and partial finder degradation;
92
+ - defocus and motion blur;
93
+ - low camera pixel coverage per module;
94
+ - JPEG compression and repeated image resizing;
95
+ - shadows, glare, white-balance shifts, and saturation changes;
96
+ - cheap printing, ink spread, paper tint, and camera recapture.
97
+
98
+ 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
@@ -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.1.0/dist/quadqr.min.js"></script>
59
+ <script src="https://cdn.jsdelivr.net/npm/quadqr-js@1.4.1/dist/quadqr.min.js"></script>
60
60
  <script>
61
61
  await QuadQR.initWasm();
62
62
  </script>
package/package.json CHANGED
@@ -1,34 +1,29 @@
1
1
  {
2
2
  "name": "quadqr-js",
3
- "version": "1.2.0",
4
- "description": "QuadQR: experimental four-state RGBW matrix code with Spectrum ECC, compression, Ed25519 signing, browser/Node scanning, diagnostics, stress testing, and optional AES-256-GCM security.",
3
+ "version": "1.4.2",
4
+ "description": "QuadQR: experimental RGBW matrix code with optional experimental High Density Mode, Spectrum ECC 2.0, multi-frame camera scanning, advanced calibration, Reliability Lab, and 3D perspective recovery.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "browser": "./dist/browser.js",
9
- "types": "./types/index.d.ts",
10
9
  "unpkg": "./dist/quadqr.min.js",
11
10
  "jsdelivr": "./dist/quadqr.min.js",
12
11
  "exports": {
13
12
  ".": {
14
- "types": "./types/index.d.ts",
15
13
  "import": "./dist/index.js",
16
14
  "require": "./dist/index.cjs",
17
15
  "default": "./dist/index.js"
18
16
  },
19
17
  "./browser": {
20
- "types": "./types/index.d.ts",
21
18
  "import": "./dist/browser.js",
22
19
  "default": "./dist/browser.js"
23
20
  },
24
21
  "./node": {
25
- "types": "./types/node.d.ts",
26
22
  "import": "./dist/node.js",
27
23
  "require": "./dist/node.cjs",
28
24
  "default": "./dist/node.js"
29
25
  },
30
26
  "./benchmark": {
31
- "types": "./types/benchmark.d.ts",
32
27
  "import": "./dist/benchmark.js",
33
28
  "require": "./dist/benchmark.cjs",
34
29
  "default": "./dist/benchmark.js"
@@ -40,7 +35,6 @@
40
35
  },
41
36
  "files": [
42
37
  "dist",
43
- "types",
44
38
  "bin",
45
39
  "docs",
46
40
  "FORMAT.md",
@@ -59,7 +53,8 @@
59
53
  "test": "node tests/self-test.js && node tests/package-test.js",
60
54
  "benchmark": "node scripts/benchmark.js",
61
55
  "pack:check": "npm run build && npm pack --dry-run",
62
- "prepublishOnly": "npm run build && npm test"
56
+ "prepublishOnly": "npm run build && npm test",
57
+ "test:demo": "node tests/demo-worker-test.js"
63
58
  },
64
59
  "engines": {
65
60
  "node": ">=20.19"
@@ -82,6 +77,8 @@
82
77
  "qr",
83
78
  "rgb",
84
79
  "rgbw",
80
+ "high-density",
81
+ "triangle16",
85
82
  "matrix-code",
86
83
  "barcode",
87
84
  "reed-solomon",
@@ -92,9 +89,13 @@
92
89
  "aes-gcm",
93
90
  "wasm",
94
91
  "compression",
92
+ "brotli",
95
93
  "ed25519",
96
94
  "scan-diagnostics",
97
- "print-qr"
95
+ "print-qr",
96
+ "reliability-lab",
97
+ "perspective-correction",
98
+ "soft-decoding"
98
99
  ],
99
100
  "sideEffects": false
100
101
  }
@@ -1,8 +0,0 @@
1
- import type { EccLevel } from "./index.js";
2
- export const STANDARD_QR_BYTE_CAPACITY: Readonly<Record<EccLevel, readonly number[]>>;
3
- export function getStandardQrByteCapacity(version: number, ecc?: EccLevel): number;
4
- export function compareCapacity(version: number, ecc?: EccLevel): Record<string, number | string | null>;
5
- export function calculateCapacityPlan(options?: { payload?: string | Uint8Array; payloadBytes?: number; ecc?: EccLevel; compression?: "none" | "auto" | "lz"; signed?: boolean; keyId?: string; embedPublicKey?: boolean }): Record<string, unknown>;
6
- export function buildCapacityComparison(options?: { ecc?: EccLevel; versions?: number[] }): Array<Record<string, number | string | null>>;
7
- export function benchmarkCodec(options?: Record<string, unknown>): Record<string, unknown>;
8
- export function benchmarkReport(options?: Record<string, unknown>): Record<string, unknown>;
package/types/index.d.ts DELETED
@@ -1,375 +0,0 @@
1
- export type EccLevel = "L" | "M" | "Q" | "H";
2
- export type RenderStyle = "classic" | "depth" | "soft" | "inset";
3
- export type RenderMode = "screen" | "print";
4
- export type CompressionMode = "none" | "auto" | "lz";
5
- export type SecurityMode = "password" | "raw-key";
6
-
7
- export interface Palette {
8
- black?: string;
9
- white?: string;
10
- red?: string;
11
- green?: string;
12
- blue?: string;
13
- }
14
-
15
- export interface EncodeOptions {
16
- version?: number | "auto";
17
- minVersion?: number;
18
- maxVersion?: number;
19
- ecc?: EccLevel;
20
- maskId?: number;
21
- text?: boolean;
22
- compression?: CompressionMode;
23
- }
24
-
25
- export interface SigningOptions {
26
- /** Private Ed25519 key used to create the signature. Never embed or distribute it. */
27
- privateKey: CryptoKey | Uint8Array | ArrayBuffer;
28
- /** Optional compact identifier stored with the signature so a verifier can select a trusted public key. */
29
- keyId?: string;
30
- /** Optional public key used only when embedPublicKey is explicitly enabled. */
31
- publicKey?: CryptoKey | Uint8Array | ArrayBuffer;
32
- /** Embed the public key for self-contained integrity checks. Default: false. */
33
- embedPublicKey?: boolean;
34
- }
35
-
36
- export interface SignedEncodeOptions extends EncodeOptions, SigningOptions {}
37
-
38
- export interface PasswordSecurity {
39
- mode: "password";
40
- password: string;
41
- iterations?: number;
42
- keyId?: string | Uint8Array | false;
43
- }
44
-
45
- export interface RawKeySecurity {
46
- mode: "raw-key";
47
- key: string | Uint8Array | ArrayBuffer;
48
- keyId?: string | Uint8Array | false;
49
- }
50
-
51
- export interface SecureEncodeOptions extends EncodeOptions {
52
- security: PasswordSecurity | RawKeySecurity;
53
- signing?: SigningOptions;
54
- }
55
-
56
- export interface QuadQRCode {
57
- matrix: number[][];
58
- version: number;
59
- size: number;
60
- formatVersion: number;
61
- eccLevel: EccLevel;
62
- payloadBytes: number;
63
- capacityBytes: number;
64
- secure?: boolean;
65
- compressed?: boolean;
66
- compression?: "none" | "lz";
67
- signed?: boolean;
68
- security?: SecurityMetadata | null;
69
- [key: string]: unknown;
70
- }
71
-
72
- export interface SecurityMetadata {
73
- securePayloadVersion?: number;
74
- mode?: SecurityMode;
75
- algorithm?: string;
76
- kdf?: string | null;
77
- iterations?: number | null;
78
- keyId?: string | null;
79
- keyIdHex?: string | null;
80
- keyIdAuto?: boolean;
81
- authenticated?: boolean;
82
- decrypted?: boolean;
83
- [key: string]: unknown;
84
- }
85
-
86
- export interface ScanDiagnostics {
87
- confidence: number;
88
- cellConfidence: number;
89
- structureConfidence: number;
90
- geometryConfidence: number;
91
- calibrationConfidence: number;
92
- eccUtilization: number;
93
- correctedErrors: number;
94
- erasureSymbols: number;
95
- stages?: Record<string, boolean>;
96
- failedStage?: string | null;
97
- geometryCandidates?: unknown[];
98
- sampled?: Record<string, unknown> | null;
99
- [key: string]: unknown;
100
- }
101
-
102
- export interface DecodeResult {
103
- payload: Uint8Array;
104
- text: string | null;
105
- version: number;
106
- size: number;
107
- formatVersion: number;
108
- eccLevel: EccLevel;
109
- secure: boolean;
110
- requiresDecryption?: boolean;
111
- decrypted?: boolean;
112
- security?: SecurityMetadata | null;
113
- encryptedPayload?: Uint8Array;
114
- protectedPayload?: Uint8Array;
115
- compressed?: boolean;
116
- compression?: "none" | "lz";
117
- signed?: boolean;
118
- /** Legacy v1 signer label, if decoding an older signed symbol. */
119
- signer?: string | null;
120
- signingKeyId?: string | null;
121
- hasEmbeddedPublicKey?: boolean;
122
- signatureVerified?: boolean | null;
123
- signatureTrusted?: boolean | null;
124
- signatureTrustSource?: "external" | "embedded" | null;
125
- confidence?: number;
126
- geometryConfidence?: number;
127
- calibrationConfidence?: number;
128
- structureConfidence?: number;
129
- correctedErrors?: number;
130
- eccUtilization?: number;
131
- diagnostics?: ScanDiagnostics;
132
- [key: string]: unknown;
133
- }
134
-
135
- export interface ImageDataLike {
136
- width: number;
137
- height: number;
138
- data: Uint8ClampedArray | Uint8Array;
139
- }
140
-
141
- export interface LogoRenderOptions {
142
- /** Loaded CanvasImageSource in canvas rendering, ImageDataLike in pixel rendering, or URL/data URL in SVG rendering. */
143
- source: CanvasImageSource | ImageDataLike | string;
144
- /** Logo width/height as a fraction of the symbol area. Clamped to 0.05..0.30. Default: 0.18. */
145
- size?: number | "auto";
146
- /** Clear the modules behind the logo with a solid background before drawing it. */
147
- clearBackground?: boolean;
148
- /** Background padding around the logo in modules. Default: 0.65. */
149
- padding?: number;
150
- /** Rounded background corner radius in modules. Default: 0.8. */
151
- radius?: number;
152
- /** Background color used when clearBackground is enabled. Default: palette white. */
153
- backgroundColor?: string;
154
- }
155
-
156
- export interface CameraFinderDiagnostic {
157
- x: number;
158
- y: number;
159
- moduleSize: number;
160
- confirmations?: number;
161
- score?: number;
162
- }
163
-
164
- export interface CameraGeometryDiagnostic {
165
- version: number;
166
- size: number;
167
- score: number;
168
- estimatedSize?: number;
169
- alignmentScore?: number;
170
- alignmentGridScore?: number;
171
- finders?: {
172
- topLeft: CameraFinderDiagnostic;
173
- topRight: CameraFinderDiagnostic;
174
- bottomLeft: CameraFinderDiagnostic;
175
- };
176
- [key: string]: unknown;
177
- }
178
-
179
- export interface CameraDiagnosticEvent {
180
- type: "camera-ready" | "frame" | "method" | "success" | string;
181
- timestamp: number;
182
- frame: number;
183
- state?: "trying" | "miss" | "failed" | "decoded" | string;
184
- method?: string;
185
- message?: string;
186
- elapsedMs?: number;
187
- missStreak?: number;
188
- scanWidth?: number;
189
- scanHeight?: number;
190
- frameWidth?: number;
191
- frameHeight?: number;
192
- scanRect?: { x: number; y: number; width: number; height: number };
193
- finderCount?: number;
194
- finders?: CameraFinderDiagnostic[];
195
- finderMethod?: string | null;
196
- finderPasses?: Array<{ method: string; finderCount: number; threshold?: number; geometryCount?: number }>;
197
- geometry?: CameraGeometryDiagnostic | null;
198
- [key: string]: unknown;
199
- }
200
-
201
- export interface RenderOptions {
202
- /** Exact square output size in pixels. If neither imageSize nor moduleSize is supplied, defaults to 720. */
203
- imageSize?: number;
204
- /** Legacy/low-level pixels per module sizing. Used when imageSize is not supplied. */
205
- moduleSize?: number;
206
- quietZone?: number;
207
- palette?: Palette;
208
- style?: RenderStyle;
209
- /** Screen defaults or print-safe palette/quiet-zone/classic-style behavior. */
210
- mode?: RenderMode;
211
- renderMode?: RenderMode;
212
- allowStyledPrint?: boolean;
213
- allowUnsafePrintQuietZone?: boolean;
214
- logo?: CanvasImageSource | ImageDataLike | string | LogoRenderOptions;
215
- logoSize?: number;
216
- logoClearBackground?: boolean;
217
- logoPadding?: number;
218
- logoRadius?: number;
219
- logoBackgroundColor?: string;
220
- [key: string]: unknown;
221
- }
222
-
223
- export interface ScanOptions {
224
- debug?: boolean;
225
- debugMatrices?: boolean;
226
- minVersion?: number;
227
- maxVersion?: number;
228
- perspective?: boolean;
229
- axisAlignedFallback?: boolean;
230
- maxDimension?: number;
231
- sampleRadius?: number;
232
- robustSampleRadius?: number;
233
- adaptiveSampling?: boolean;
234
- spatialColorNormalization?: boolean;
235
- structureTolerance?: number;
236
- maxErasureConfidence?: number;
237
- geometryRefinement?: boolean;
238
- finderRecovery?: boolean;
239
- finderAutoColorBlackClip?: number;
240
- finderAutoColorWhiteClip?: number;
241
- finderAutoColorHighlightPercentile?: number;
242
- finderAutoColorOutputHighlight?: number;
243
- finderAutoColorAnalysisInset?: number;
244
- finderAutoColorAnalysisInsets?: number[];
245
- finderAutoColorMinimumInputRange?: number;
246
- finderAutoColorTargetSamples?: number;
247
- autoEnhanceRecovery?: boolean;
248
- autoEnhanceWhenNoGeometry?: boolean;
249
- autoEnhanceBlackClip?: number;
250
- autoEnhanceWhiteClip?: number;
251
- autoEnhanceSaturation?: number;
252
- autoEnhanceTargetSamples?: number;
253
- fullFrameAutoEnhanceRecovery?: boolean;
254
- rectifiedAutoEnhanceRecovery?: boolean;
255
- rectifiedRecoveryModuleSize?: number;
256
- rectifiedRecoveryRadiusRatio?: number;
257
- rectifiedAutoEnhanceBlackClip?: number;
258
- rectifiedAutoEnhanceWhiteClip?: number;
259
- rectifiedAutoEnhanceSaturation?: number;
260
- rectifiedAutoEnhanceHighlightFraction?: number;
261
- videoCropMode?: "visible" | "full";
262
- videoObjectFit?: string;
263
- videoObjectPosition?: string;
264
- videoCropInset?: number;
265
- refinementOffset?: number;
266
- refinementStructureThreshold?: number;
267
- refinementDecodeThreshold?: number;
268
- refinementDecodeCandidates?: number;
269
- [key: string]: unknown;
270
- }
271
-
272
- export interface CameraFrameMeta {
273
- frame: number;
274
- imageData: ImageDataLike;
275
- scanWidth: number;
276
- scanHeight: number;
277
- sourceRect?: { x: number; y: number; width: number; height: number; cropped?: boolean } | null;
278
- enhancedImageData?: ImageDataLike | null;
279
- enhancedRect?: { x: number; y: number; width: number; height: number } | null;
280
- enhancement?: { method?: string; cropInset?: number; analysisInset?: number; [key: string]: unknown } | null;
281
- diagnostic?: Record<string, unknown> | null;
282
- }
283
-
284
- export interface CameraScanOptions extends ScanOptions {
285
- scanInterval?: number;
286
- stopOnResult?: boolean;
287
- multiFrame?: boolean;
288
- multiFrameWindow?: number;
289
- multiFrameMinFrames?: number;
290
- cameraAutoColorRecovery?: boolean;
291
- cameraAutoColorEvery?: number;
292
- cameraAutoColorBlackClip?: number;
293
- cameraAutoColorWhiteClip?: number;
294
- cameraAutoColorHighlightPercentile?: number;
295
- cameraAutoColorOutputHighlight?: number;
296
- cameraAutoColorAnalysisInset?: number;
297
- cameraAutoColorAnalysisInsets?: number[];
298
- cameraAutoColorCropInsets?: number[];
299
- cameraAutoColorMinimumInputRange?: number;
300
- cameraAutoColorTargetSamples?: number;
301
- cameraAutoEnhanceEvery?: number;
302
- cameraFinderRecoveryEvery?: number;
303
- constraints?: MediaStreamConstraints;
304
- onResult?: (result: DecodeResult, frame?: CameraFrameMeta | null) => void | Promise<void>;
305
- onDecode?: (result: DecodeResult, frame?: CameraFrameMeta | null) => void | Promise<void>;
306
- onScanMiss?: (error: Error) => void;
307
- onDiagnostic?: (event: CameraDiagnosticEvent) => void;
308
- }
309
-
310
- export const FORMAT_VERSION: number;
311
- export const MIN_VERSION: number;
312
- export const MAX_VERSION: number;
313
- export const DEFAULT_ECC_LEVEL: EccLevel;
314
- export const RENDER_MODES: Readonly<{ SCREEN: "screen"; PRINT: "print" }>;
315
- export const PRINT_PALETTE: Readonly<Required<Palette>>;
316
- export const COMPRESSION_MODES: Readonly<Record<string, CompressionMode>>;
317
- export const SIGNATURE_ALGORITHMS: Readonly<{ ED25519: "Ed25519" }>;
318
- export const CELL: Readonly<{ BLACK: -1; RED: 0; GREEN: 1; BLUE: 2; WHITE: 3 }>;
319
- export const DEFAULT_PALETTE: Readonly<Required<Palette>>;
320
- export const RENDER_STYLES: Readonly<Record<string, RenderStyle>>;
321
- export const ECC_LEVELS: Readonly<Record<EccLevel, { id: number; paritySymbols: number; correctableSymbolsPerBlock: number }>>;
322
- export const SECURITY_MODES: Readonly<{ PASSWORD: "password"; RAW_KEY: "raw-key" }>;
323
- export const SECURITY_ALGORITHMS: Readonly<{ AES_256_GCM: "AES-256-GCM" }>;
324
- export const SECURE_PAYLOAD_VERSION: number;
325
- export const DEFAULT_PBKDF2_ITERATIONS: number;
326
-
327
- export function encodeText(text: string, options?: EncodeOptions): QuadQRCode;
328
- export function encodeBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options?: EncodeOptions): QuadQRCode;
329
- export function encodeUint8Array(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options?: EncodeOptions): QuadQRCode;
330
- export function encodeSignedText(text: string, options: SignedEncodeOptions): Promise<QuadQRCode>;
331
- export function encodeSignedBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options: SignedEncodeOptions): Promise<QuadQRCode>;
332
- export function encodeSecureText(text: string, options: SecureEncodeOptions): Promise<QuadQRCode>;
333
- export function encodeSecureBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options: SecureEncodeOptions): Promise<QuadQRCode>;
334
- export function compressPayload(input: Uint8Array | ArrayBuffer | ArrayLike<number>): Uint8Array;
335
- export function decompressPayload(input: Uint8Array | ArrayBuffer | ArrayLike<number>, expectedLength?: number | null): Uint8Array;
336
- export function deriveSigningKeyId(publicKey: CryptoKey | Uint8Array | ArrayBuffer, bytes?: number): Promise<string>;
337
- export function generateSigningKeyPair(): Promise<{ privateKey: CryptoKey; publicKey: CryptoKey; privateKeyPkcs8: Uint8Array; publicKeyBytes: Uint8Array; keyId: string; algorithm: "Ed25519" }>;
338
- export function decodeMatrix(matrix: number[][], options?: Record<string, unknown>): DecodeResult;
339
- export function decodeUint8Array(matrix: number[][], options?: Record<string, unknown>): Uint8Array;
340
- export function decryptDecoded(result: DecodeResult, credentials: { password: string } | { key: string | Uint8Array | ArrayBuffer }): Promise<DecodeResult>;
341
- export function verifyDecodedSignature(result: DecodeResult, options?: {
342
- publicKey?: CryptoKey | Uint8Array | ArrayBuffer;
343
- trustedPublicKey?: CryptoKey | Uint8Array | ArrayBuffer;
344
- trustedKeys?: Record<string, CryptoKey | Uint8Array | ArrayBuffer> | Map<string, CryptoKey | Uint8Array | ArrayBuffer>;
345
- allowEmbeddedKey?: boolean;
346
- }): Promise<DecodeResult>;
347
- export function renderToCanvas(codeOrMatrix: QuadQRCode | number[][], canvas: HTMLCanvasElement, options?: RenderOptions): HTMLCanvasElement;
348
- export function renderToImageData(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions): ImageDataLike;
349
- export function renderToSVG(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions): string;
350
- export function estimateSafeLogoSize(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions & { ecc?: EccLevel; utilization?: number }): number;
351
- export function findMaxSafeLogoSize(code: QuadQRCode, options: RenderOptions & { minSize?: number; maxSize?: number; iterations?: number }): { safeSize: number; testedMax: number; iterations: number; empirical: boolean };
352
- export function getPrintGuidance(codeOrMatrix: QuadQRCode | number[][], options?: { quietZone?: number; physicalSizeMm?: number; dpi?: number; minimumModuleMm?: number }): Record<string, unknown>;
353
- export function scanImageData(imageData: ImageDataLike, options?: ScanOptions): DecodeResult;
354
- export function debugScanImageData(imageData: ImageDataLike, options?: ScanOptions): { ok: boolean; result?: DecodeResult; error?: string; debug?: ScanDiagnostics | null };
355
- export function scanFile(file: Blob, options?: ScanOptions): Promise<DecodeResult>;
356
- export function scanVideoFrame(video: HTMLVideoElement, options?: ScanOptions): DecodeResult;
357
- export function startCameraScanner(video: HTMLVideoElement, options?: CameraScanOptions): Promise<{ stop(): void; scanNow(): DecodeResult; stream: MediaStream; video: HTMLVideoElement }>;
358
- export function applyStressDistortion(imageData: ImageDataLike, type: string, severity?: number, options?: Record<string, unknown>): ImageDataLike;
359
- export const STRESS_PROFILES: readonly Readonly<{ id: string; label: string; type: string; severity: number; weight: number }>[];
360
- export function runImageStressTest(imageData: ImageDataLike, expected?: { version?: number; crc32?: number }, options?: Record<string, unknown>): Record<string, unknown>;
361
- export function assessScanability(code: QuadQRCode, renderOptions?: RenderOptions, options?: Record<string, unknown>): Record<string, unknown>;
362
- export function rectifyDetectedCode(imageData: ImageDataLike, options?: Record<string, unknown>): ImageDataLike;
363
- export function rotateMatrix(matrix: number[][], quarterTurns?: number): number[][];
364
- export function getVersionInfo(version: number, options?: { ecc?: EccLevel }): Record<string, unknown>;
365
- export function crc32(bytes: Uint8Array): number;
366
- export function installCrc32Accelerator(accelerator?: ((bytes: Uint8Array) => number) | null): void;
367
- export function generateRaw256Key(): Uint8Array;
368
- export function normalizeRaw256Key(key: string | Uint8Array | ArrayBuffer): Uint8Array;
369
- export function bytesToHex(bytes: Uint8Array): string;
370
-
371
- export function initWasm(options?: { url?: string | URL; bytes?: Uint8Array | ArrayBuffer }): Promise<{ enabled: true; module: string; accelerators: readonly string[]; bytes: number }>;
372
- export function getWasmState(): { enabled: true; module: string; accelerators: readonly string[]; bytes: number } | null;
373
- export function disableWasm(): void;
374
-
375
- export const internals: Readonly<Record<string, unknown>>;
package/types/node.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export * from "./index.js";
2
- import type { DecodeResult, ImageDataLike, QuadQRCode, RenderOptions, ScanOptions } from "./index.js";
3
-
4
- export function decodePNG(input: Uint8Array | ArrayBuffer): ImageDataLike;
5
- export function encodePNG(imageData: ImageDataLike, options?: { compressionLevel?: number }): Buffer;
6
- export function toPNG(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions & { compressionLevel?: number }): Buffer;
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 }>;
10
- export function scanBuffer(input: Uint8Array | ArrayBuffer, options?: ScanOptions): Promise<DecodeResult>;
11
- export function scanFile(filename: string | URL, options?: ScanOptions): Promise<DecodeResult>;