quadqr-js 0.7.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.
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "quadqr-js",
3
+ "version": "0.7.0",
4
+ "description": "QuadQR: experimental four-state RGBW matrix code with Spectrum ECC, browser/Node scanning, CDN builds, and optional AES-256-GCM secure payloads.",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "browser": "./dist/browser.js",
9
+ "types": "./types/index.d.ts",
10
+ "unpkg": "./dist/quadqr.min.js",
11
+ "jsdelivr": "./dist/quadqr.min.js",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./types/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./browser": {
20
+ "types": "./types/index.d.ts",
21
+ "import": "./dist/browser.js",
22
+ "default": "./dist/browser.js"
23
+ },
24
+ "./node": {
25
+ "types": "./types/node.d.ts",
26
+ "import": "./dist/node.js",
27
+ "require": "./dist/node.cjs",
28
+ "default": "./dist/node.js"
29
+ },
30
+ "./benchmark": {
31
+ "types": "./types/benchmark.d.ts",
32
+ "import": "./dist/benchmark.js",
33
+ "require": "./dist/benchmark.cjs",
34
+ "default": "./dist/benchmark.js"
35
+ },
36
+ "./quadqr.js": "./dist/quadqr.js",
37
+ "./quadqr.min.js": "./dist/quadqr.min.js",
38
+ "./wasm/quadqr-core.wasm": "./dist/wasm/quadqr-core.wasm",
39
+ "./package.json": "./package.json"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "types",
44
+ "bin",
45
+ "docs",
46
+ "FORMAT.md",
47
+ "README.md",
48
+ "LICENSE"
49
+ ],
50
+ "bin": {
51
+ "quadqr": "./bin/quadqr.js"
52
+ },
53
+ "scripts": {
54
+ "build": "node scripts/build.js",
55
+ "start": "node scripts/serve.js",
56
+ "demo": "node scripts/serve.js",
57
+ "docs": "node scripts/serve.js --docs",
58
+ "test": "node tests/self-test.js && node tests/package-test.js",
59
+ "benchmark": "node scripts/benchmark.js",
60
+ "pack:check": "npm run build && npm pack --dry-run",
61
+ "prepublishOnly": "npm run build && npm test"
62
+ },
63
+ "engines": {
64
+ "node": ">=20.19"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public"
68
+ },
69
+ "repository": {
70
+ "type": "git",
71
+ "url": "git+https://github.com/akanshsirohi/QuadQR.git"
72
+ },
73
+ "bugs": {
74
+ "url": "https://github.com/akanshsirohi/QuadQR/issues"
75
+ },
76
+ "homepage": "https://github.com/akanshsirohi/QuadQR#readme",
77
+ "author": "Akansh Sirohi",
78
+ "license": "MIT",
79
+ "keywords": [
80
+ "quadqr",
81
+ "qr",
82
+ "rgb",
83
+ "rgbw",
84
+ "matrix-code",
85
+ "barcode",
86
+ "reed-solomon",
87
+ "ecc",
88
+ "scanner",
89
+ "camera-scanner",
90
+ "encryption",
91
+ "aes-gcm",
92
+ "wasm"
93
+ ],
94
+ "sideEffects": false
95
+ }
@@ -0,0 +1,7 @@
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>;
5
+ export function buildCapacityComparison(options?: { ecc?: EccLevel; versions?: number[] }): Array<Record<string, number | string>>;
6
+ export function benchmarkCodec(options?: Record<string, unknown>): Record<string, unknown>;
7
+ export function benchmarkReport(options?: Record<string, unknown>): string;
@@ -0,0 +1,139 @@
1
+ export type EccLevel = "L" | "M" | "Q" | "H";
2
+ export type RenderStyle = "classic" | "depth" | "soft" | "inset";
3
+ export type SecurityMode = "password" | "raw-key";
4
+
5
+ export interface Palette {
6
+ black?: string;
7
+ white?: string;
8
+ red?: string;
9
+ green?: string;
10
+ blue?: string;
11
+ }
12
+
13
+ export interface EncodeOptions {
14
+ version?: number;
15
+ ecc?: EccLevel;
16
+ maskId?: number;
17
+ text?: boolean;
18
+ }
19
+
20
+ export interface PasswordSecurity {
21
+ mode: "password";
22
+ password: string;
23
+ iterations?: number;
24
+ keyId?: string | Uint8Array | false;
25
+ }
26
+
27
+ export interface RawKeySecurity {
28
+ mode: "raw-key";
29
+ key: string | Uint8Array | ArrayBuffer;
30
+ keyId?: string | Uint8Array | false;
31
+ }
32
+
33
+ export interface SecureEncodeOptions extends EncodeOptions {
34
+ security: PasswordSecurity | RawKeySecurity;
35
+ }
36
+
37
+ export interface QuadQRCode {
38
+ matrix: number[][];
39
+ version: number;
40
+ size: number;
41
+ formatVersion: number;
42
+ eccLevel: EccLevel;
43
+ payloadBytes: number;
44
+ capacityBytes: number;
45
+ secure?: boolean;
46
+ security?: SecurityMetadata | null;
47
+ [key: string]: unknown;
48
+ }
49
+
50
+ export interface SecurityMetadata {
51
+ securePayloadVersion?: number;
52
+ mode?: SecurityMode;
53
+ algorithm?: string;
54
+ kdf?: string | null;
55
+ iterations?: number | null;
56
+ keyId?: string | null;
57
+ keyIdHex?: string | null;
58
+ keyIdAuto?: boolean;
59
+ authenticated?: boolean;
60
+ decrypted?: boolean;
61
+ [key: string]: unknown;
62
+ }
63
+
64
+ export interface DecodeResult {
65
+ payload: Uint8Array;
66
+ text: string | null;
67
+ version: number;
68
+ size: number;
69
+ formatVersion: number;
70
+ eccLevel: EccLevel;
71
+ secure: boolean;
72
+ requiresDecryption?: boolean;
73
+ decrypted?: boolean;
74
+ security?: SecurityMetadata | null;
75
+ encryptedPayload?: Uint8Array;
76
+ [key: string]: unknown;
77
+ }
78
+
79
+ export interface ImageDataLike {
80
+ width: number;
81
+ height: number;
82
+ data: Uint8ClampedArray | Uint8Array;
83
+ }
84
+
85
+ export interface RenderOptions {
86
+ moduleSize?: number;
87
+ quietZone?: number;
88
+ palette?: Palette;
89
+ style?: RenderStyle;
90
+ [key: string]: unknown;
91
+ }
92
+
93
+ export interface ScanOptions {
94
+ minVersion?: number;
95
+ maxVersion?: number;
96
+ perspective?: boolean;
97
+ axisAlignedFallback?: boolean;
98
+ [key: string]: unknown;
99
+ }
100
+
101
+ export const FORMAT_VERSION: number;
102
+ export const MIN_VERSION: number;
103
+ export const MAX_VERSION: number;
104
+ export const DEFAULT_ECC_LEVEL: EccLevel;
105
+ export const CELL: Readonly<{ BLACK: -1; RED: 0; GREEN: 1; BLUE: 2; WHITE: 3 }>;
106
+ export const DEFAULT_PALETTE: Readonly<Required<Palette>>;
107
+ export const RENDER_STYLES: Readonly<Record<string, RenderStyle>>;
108
+ export const ECC_LEVELS: Readonly<Record<EccLevel, { id: number; paritySymbols: number; correctableSymbolsPerBlock: number }>>;
109
+ export const SECURITY_MODES: Readonly<{ PASSWORD: "password"; RAW_KEY: "raw-key" }>;
110
+ export const SECURITY_ALGORITHMS: Readonly<{ AES_256_GCM: "AES-256-GCM" }>;
111
+ export const SECURE_PAYLOAD_VERSION: number;
112
+ export const DEFAULT_PBKDF2_ITERATIONS: number;
113
+
114
+ export function encodeText(text: string, options?: EncodeOptions): QuadQRCode;
115
+ export function encodeBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options?: EncodeOptions): QuadQRCode;
116
+ export function encodeSecureText(text: string, options: SecureEncodeOptions): Promise<QuadQRCode>;
117
+ export function encodeSecureBytes(input: Uint8Array | ArrayBuffer | ArrayLike<number>, options: SecureEncodeOptions): Promise<QuadQRCode>;
118
+ export function decodeMatrix(matrix: number[][], options?: Record<string, unknown>): DecodeResult;
119
+ export function decryptDecoded(result: DecodeResult, credentials: { password: string } | { key: string | Uint8Array | ArrayBuffer }): Promise<DecodeResult>;
120
+ export function renderToCanvas(codeOrMatrix: QuadQRCode | number[][], canvas: HTMLCanvasElement, options?: RenderOptions): HTMLCanvasElement;
121
+ export function renderToImageData(codeOrMatrix: QuadQRCode | number[][], options?: RenderOptions): ImageDataLike;
122
+ export function scanImageData(imageData: ImageDataLike, options?: ScanOptions): DecodeResult;
123
+ export function scanFile(file: Blob, options?: ScanOptions): Promise<DecodeResult>;
124
+ export function scanVideoFrame(video: HTMLVideoElement, options?: ScanOptions): DecodeResult;
125
+ export function startCameraScanner(video: HTMLVideoElement, options?: ScanOptions & { onDecode?: (result: DecodeResult) => void | Promise<void>; onError?: (error: Error) => void; scanInterval?: number; constraints?: MediaStreamConstraints }): Promise<{ stop(): void; scanNow(): DecodeResult; stream: MediaStream }>;
126
+ export function rectifyDetectedCode(imageData: ImageDataLike, options?: Record<string, unknown>): ImageDataLike;
127
+ export function rotateMatrix(matrix: number[][], quarterTurns?: number): number[][];
128
+ export function getVersionInfo(version: number, options?: { ecc?: EccLevel }): Record<string, unknown>;
129
+ export function crc32(bytes: Uint8Array): number;
130
+ export function installCrc32Accelerator(accelerator?: ((bytes: Uint8Array) => number) | null): void;
131
+ export function generateRaw256Key(): Uint8Array;
132
+ export function normalizeRaw256Key(key: string | Uint8Array | ArrayBuffer): Uint8Array;
133
+ export function bytesToHex(bytes: Uint8Array): string;
134
+
135
+ export function initWasm(options?: { url?: string | URL; bytes?: Uint8Array | ArrayBuffer }): Promise<{ enabled: true; module: string; accelerators: readonly string[]; bytes: number }>;
136
+ export function getWasmState(): { enabled: true; module: string; accelerators: readonly string[]; bytes: number } | null;
137
+ export function disableWasm(): void;
138
+
139
+ export const internals: Readonly<Record<string, unknown>>;
@@ -0,0 +1,9 @@
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 scanBuffer(input: Uint8Array | ArrayBuffer, options?: ScanOptions): Promise<DecodeResult>;
9
+ export function scanFile(filename: string | URL, options?: ScanOptions): Promise<DecodeResult>;