qrdx 0.0.46 → 0.0.47
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/LICENSE +21 -0
- package/README.md +353 -300
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -7
- package/dist/index.mjs.map +1 -1
- package/dist/qr-code-canvas.js +12 -0
- package/dist/qr-code-canvas.js.map +1 -0
- package/dist/qr-code-canvas.mjs +12 -0
- package/dist/qr-code-canvas.mjs.map +1 -0
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/art-trace.d.ts +46 -0
- package/dist/src/art-trace.d.ts.map +1 -0
- package/dist/src/art.d.ts +138 -0
- package/dist/src/art.d.ts.map +1 -0
- package/dist/src/body-patterns.d.ts +34 -0
- package/dist/src/body-patterns.d.ts.map +1 -0
- package/dist/src/codegen.d.ts +5 -5
- package/dist/src/codegen.d.ts.map +1 -1
- package/dist/src/codeword-map.d.ts +40 -0
- package/dist/src/codeword-map.d.ts.map +1 -0
- package/dist/src/constants.d.ts +4 -7
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/corner-dot.d.ts +3 -1
- package/dist/src/corner-dot.d.ts.map +1 -1
- package/dist/src/corner-eye.d.ts +5 -2
- package/dist/src/corner-eye.d.ts.map +1 -1
- package/dist/src/detection.d.ts.map +1 -1
- package/dist/src/download.d.ts +22 -5
- package/dist/src/download.d.ts.map +1 -1
- package/dist/src/eps.d.ts +62 -0
- package/dist/src/eps.d.ts.map +1 -0
- package/dist/src/frame-icons.d.ts +11 -0
- package/dist/src/frame-icons.d.ts.map +1 -0
- package/dist/src/frame-import.d.ts +61 -0
- package/dist/src/frame-import.d.ts.map +1 -0
- package/dist/src/frame-spec.d.ts +24 -0
- package/dist/src/frame-spec.d.ts.map +1 -0
- package/dist/src/frame-styles.d.ts +50 -0
- package/dist/src/frame-styles.d.ts.map +1 -0
- package/dist/src/frame.d.ts +126 -0
- package/dist/src/frame.d.ts.map +1 -0
- package/dist/src/frames/builtin.d.ts +8 -0
- package/dist/src/frames/builtin.d.ts.map +1 -0
- package/dist/src/frames/official.d.ts +18 -0
- package/dist/src/frames/official.d.ts.map +1 -0
- package/dist/src/helpers.d.ts +15 -2
- package/dist/src/helpers.d.ts.map +1 -1
- package/dist/src/index.d.ts +24 -13
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logo-budget.d.ts +54 -0
- package/dist/src/logo-budget.d.ts.map +1 -0
- package/dist/src/logo-cleanup.d.ts +25 -0
- package/dist/src/logo-cleanup.d.ts.map +1 -0
- package/dist/src/logo.d.ts +28 -0
- package/dist/src/logo.d.ts.map +1 -0
- package/dist/src/print.d.ts +73 -0
- package/dist/src/print.d.ts.map +1 -0
- package/dist/src/qr-code-canvas.d.ts +13 -0
- package/dist/src/qr-code-canvas.d.ts.map +1 -0
- package/dist/src/qr-code.d.ts +4 -2
- package/dist/src/qr-code.d.ts.map +1 -1
- package/dist/src/qr-outline.d.ts +41 -0
- package/dist/src/qr-outline.d.ts.map +1 -0
- package/dist/src/qr-shape.d.ts +72 -0
- package/dist/src/qr-shape.d.ts.map +1 -0
- package/dist/src/scan-risk.d.ts +40 -0
- package/dist/src/scan-risk.d.ts.map +1 -0
- package/dist/src/scan-score.d.ts +154 -0
- package/dist/src/scan-score.d.ts.map +1 -0
- package/dist/src/shapes.d.ts +36 -0
- package/dist/src/shapes.d.ts.map +1 -0
- package/dist/src/silhouette.d.ts +28 -0
- package/dist/src/silhouette.d.ts.map +1 -0
- package/dist/src/utils/color.d.ts.map +1 -1
- package/dist/src/utils/fmt.d.ts +24 -0
- package/dist/src/utils/fmt.d.ts.map +1 -0
- package/dist/src/utils/paint.d.ts +80 -0
- package/dist/src/utils/paint.d.ts.map +1 -0
- package/dist/src/utils/parse-color.d.ts +21 -0
- package/dist/src/utils/parse-color.d.ts.map +1 -0
- package/dist/src/utils/path-data.d.ts +24 -0
- package/dist/src/utils/path-data.d.ts.map +1 -0
- package/dist/src/utils/png.d.ts +16 -0
- package/dist/src/utils/png.d.ts.map +1 -0
- package/dist/src/utils/polygon-clip.d.ts +26 -0
- package/dist/src/utils/polygon-clip.d.ts.map +1 -0
- package/dist/src/utils/print-shared.d.ts +20 -0
- package/dist/src/utils/print-shared.d.ts.map +1 -0
- package/dist/src/utils/svg-geometry.d.ts +49 -0
- package/dist/src/utils/svg-geometry.d.ts.map +1 -0
- package/dist/src/utils/svg-gradient.d.ts +59 -0
- package/dist/src/utils/svg-gradient.d.ts.map +1 -0
- package/dist/src/utils/svg-painter.d.ts +152 -0
- package/dist/src/utils/svg-painter.d.ts.map +1 -0
- package/dist/src/utils.d.ts +18 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/types/art.d.ts +64 -0
- package/dist/types/art.d.ts.map +1 -0
- package/dist/types/color.d.ts +125 -7
- package/dist/types/color.d.ts.map +1 -1
- package/dist/types/corner-dot.d.ts +52 -2
- package/dist/types/corner-dot.d.ts.map +1 -1
- package/dist/types/corner-eye.d.ts +43 -2
- package/dist/types/corner-eye.d.ts.map +1 -1
- package/dist/types/frame-spec.d.ts +3509 -0
- package/dist/types/frame-spec.d.ts.map +1 -0
- package/dist/types/frame.d.ts +68 -0
- package/dist/types/frame.d.ts.map +1 -0
- package/dist/types/image-pattern.d.ts +15 -1
- package/dist/types/image-pattern.d.ts.map +1 -1
- package/dist/types/index.d.ts +15 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +6 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/qr.d.ts +1684 -4
- package/dist/types/qr.d.ts.map +1 -1
- package/dist/types/template.d.ts +2 -2
- package/dist/types/template.d.ts.map +1 -1
- package/package.json +68 -25
- package/src/api.tsx +67 -17
- package/src/art-trace.ts +554 -0
- package/src/art.tsx +2226 -0
- package/src/body-patterns.tsx +389 -0
- package/src/codegen.ts +10 -5
- package/src/codeword-map.ts +265 -0
- package/src/constants.ts +4 -8
- package/src/corner-dot.tsx +209 -33
- package/src/corner-eye.ts +328 -60
- package/src/detection.ts +5 -11
- package/src/download.tsx +123 -52
- package/src/eps.ts +701 -0
- package/src/frame-icons.ts +325 -0
- package/src/frame-import.ts +1198 -0
- package/src/frame-spec.ts +518 -0
- package/src/frame-styles.ts +1095 -0
- package/src/frame.tsx +630 -0
- package/src/frames/builtin/banner-bottom.json +58 -0
- package/src/frames/builtin/circle.json +81 -0
- package/src/frames/builtin/rounded-border.json +60 -0
- package/src/frames/builtin/ticket.json +51 -0
- package/src/frames/builtin.ts +20 -0
- package/src/frames/official/attendance.json +110 -0
- package/src/frames/official/audio-guide.json +95 -0
- package/src/frames/official/book-now.json +103 -0
- package/src/frames/official/check-in.json +110 -0
- package/src/frames/official/christmas.json +131 -0
- package/src/frames/official/donate.json +77 -0
- package/src/frames/official/event-ticket.json +77 -0
- package/src/frames/official/feedback-bubble.json +73 -0
- package/src/frames/official/follow-us.json +83 -0
- package/src/frames/official/get-the-app.json +107 -0
- package/src/frames/official/halloween.json +80 -0
- package/src/frames/official/new-year.json +94 -0
- package/src/frames/official/order-at-table.json +86 -0
- package/src/frames/official/product-info.json +119 -0
- package/src/frames/official/register-product.json +77 -0
- package/src/frames/official/review-us.json +127 -0
- package/src/frames/official/rsvp-card.json +112 -0
- package/src/frames/official/save-contact.json +117 -0
- package/src/frames/official/scan-to-pay.json +94 -0
- package/src/frames/official/shop-window.json +81 -0
- package/src/frames/official/sign-rider.json +81 -0
- package/src/frames/official/table-tent.json +75 -0
- package/src/frames/official/wifi-card.json +89 -0
- package/src/frames/official/winter.json +142 -0
- package/src/frames/official.ts +77 -0
- package/src/helpers.ts +168 -11
- package/src/index.tsx +141 -172
- package/src/logo-budget.ts +226 -0
- package/src/logo-cleanup.ts +146 -0
- package/src/logo.tsx +137 -0
- package/src/print.ts +794 -0
- package/src/qr-code-canvas.tsx +241 -0
- package/src/qr-code.tsx +51 -16
- package/src/qr-outline.ts +511 -0
- package/src/qr-shape.ts +255 -0
- package/src/scan-risk.ts +197 -0
- package/src/scan-score.ts +1629 -0
- package/src/shapes.ts +169 -0
- package/src/silhouette.ts +334 -0
- package/src/utils/color.ts +10 -1
- package/src/utils/fmt.ts +59 -0
- package/src/utils/paint.ts +317 -0
- package/src/utils/parse-color.ts +135 -0
- package/src/utils/path-data.ts +182 -0
- package/src/utils/png.ts +175 -0
- package/src/utils/polygon-clip.ts +163 -0
- package/src/utils/print-shared.ts +74 -0
- package/src/utils/svg-geometry.ts +838 -0
- package/src/utils/svg-gradient.ts +407 -0
- package/src/utils/svg-painter.ts +946 -0
- package/src/utils.tsx +794 -385
- package/types/art.ts +74 -0
- package/types/color.ts +132 -12
- package/types/corner-dot.ts +41 -4
- package/types/corner-eye.ts +31 -4
- package/types/frame-spec.ts +748 -0
- package/types/frame.ts +67 -0
- package/types/image-pattern.ts +15 -0
- package/types/index.ts +106 -4
- package/types/qr.ts +180 -2
- package/types/template.ts +2 -2
- package/dist/cli.js +0 -4319
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: color math and module geometry */
|
|
2
|
+
import type { JSX } from "react";
|
|
3
|
+
import { type QRArt, type QRArtImage, type QRArtMode, type QRArtVariant } from "../types/art";
|
|
4
|
+
import type { Modules } from "../types/common";
|
|
5
|
+
import type { EyePosition } from "../types/qr";
|
|
6
|
+
/** Intensity used when `art.intensity` is not set. */
|
|
7
|
+
export declare const DEFAULT_ART_INTENSITY = 0.6;
|
|
8
|
+
/**
|
|
9
|
+
* Sample grid sizes `loadQRArtImage` uses per mode. 160 × 160 RGBA is about
|
|
10
|
+
* 133 KB of base64, under the ~150 KB budget for art saved in themes.
|
|
11
|
+
*/
|
|
12
|
+
export declare const QR_ART_SAMPLE_SIZES: Record<QRArtMode, number>;
|
|
13
|
+
export interface QRArtPixels {
|
|
14
|
+
/** RGBA bytes, row by row */
|
|
15
|
+
data: ArrayLike<number>;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Downsamples raw RGBA pixels (from a canvas, `sharp().raw()`, …) into the
|
|
21
|
+
* compact bitmap `art.image` expects. Works everywhere, no DOM needed.
|
|
22
|
+
* `square` crops the center square first (photos are drawn cover-fit, so
|
|
23
|
+
* the crop keeps every stored pixel useful).
|
|
24
|
+
*/
|
|
25
|
+
export declare function createQRArtImage(pixels: QRArtPixels, options?: {
|
|
26
|
+
maxSize?: number;
|
|
27
|
+
square?: boolean;
|
|
28
|
+
}): QRArtImage;
|
|
29
|
+
/**
|
|
30
|
+
* Loads an image (data URL, same-origin URL, Blob or <img>) in the browser
|
|
31
|
+
* and samples it for `art.image`. Use `createQRArtImage` on the server.
|
|
32
|
+
* Photos (mode "halftone") are cropped to their center square.
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadQRArtImage(source: string | Blob | HTMLImageElement, options?: {
|
|
35
|
+
mode?: QRArtMode;
|
|
36
|
+
maxSize?: number;
|
|
37
|
+
}): Promise<QRArtImage>;
|
|
38
|
+
/** True when `art` has a known mode and a well-formed image. */
|
|
39
|
+
export declare function isQRArtActive(art: QRArt | null | undefined): art is QRArt;
|
|
40
|
+
/** The variant `art` renders with (the mode's default when unset or foreign). */
|
|
41
|
+
export declare function getQRArtVariant(art: Pick<QRArt, "mode" | "variant">): QRArtVariant;
|
|
42
|
+
/** Row/column centers of the alignment patterns for a code of `version`. */
|
|
43
|
+
export declare function alignmentPositions(version: number, size: number): number[];
|
|
44
|
+
/**
|
|
45
|
+
* Modules that belong to function patterns (finders with separators, timing,
|
|
46
|
+
* alignment, format and version information) for a code of `version`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getQRFunctionModules(version: number): boolean[][];
|
|
49
|
+
export interface QRArtRenderOptions {
|
|
50
|
+
art: QRArt;
|
|
51
|
+
/** Module grid without margin (after any logo excavation) */
|
|
52
|
+
modules: Modules;
|
|
53
|
+
/** QR version of `modules` (1–40) */
|
|
54
|
+
version: number;
|
|
55
|
+
margin: number;
|
|
56
|
+
/** Width of one module in output units */
|
|
57
|
+
pixelSize: number;
|
|
58
|
+
/** Solid dark color (gradients: first stop) */
|
|
59
|
+
fgColor: string;
|
|
60
|
+
/** Solid light color (gradients: first stop) */
|
|
61
|
+
bgColor: string;
|
|
62
|
+
/**
|
|
63
|
+
* Draws dark modules in the caller's body pattern (finder modules are
|
|
64
|
+
* skipped by the caller). Logo "badge" uses it so the code keeps the
|
|
65
|
+
* chosen dot shape; without it, art draws round dots.
|
|
66
|
+
*/
|
|
67
|
+
body?: (modules: Modules) => JSX.Element | JSX.Element[] | null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* How much lighter (luma, 0–1) the background must be than the dots for art
|
|
71
|
+
* to render. Art needs dark modules on a light background with room in
|
|
72
|
+
* between; otherwise the plain look is kept so nothing gets worse.
|
|
73
|
+
*/
|
|
74
|
+
export declare const QR_ART_MIN_LUMA_GAP = 0.35;
|
|
75
|
+
/** Why art can't render with these colors, if it can't. */
|
|
76
|
+
export type QRArtColorIssue = "inverted" | "low-contrast";
|
|
77
|
+
/**
|
|
78
|
+
* Null when art renders with `fgColor` on `bgColor`; otherwise why not:
|
|
79
|
+
* "inverted" (dots lighter than the background) or "low-contrast" (too
|
|
80
|
+
* close). Gradients: pass the first stop, as the renderer does. Editors use
|
|
81
|
+
* this to explain why art isn't showing instead of failing silently.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getQRArtColorIssue(fgColor: string, bgColor: string): QRArtColorIssue | null;
|
|
84
|
+
/**
|
|
85
|
+
* Draws every module that is not a finder eye in the art style. Returns null
|
|
86
|
+
* when `art` is not usable (or its strength is 0), so callers fall back to
|
|
87
|
+
* the normal body pattern.
|
|
88
|
+
*/
|
|
89
|
+
export declare function renderQRArt(options: QRArtRenderOptions): JSX.Element | null;
|
|
90
|
+
/** Logo QR "badge" sizes for one code, in modules. */
|
|
91
|
+
export interface QRArtBadgeLayout {
|
|
92
|
+
/** Logo box (longest side) the strength asks for */
|
|
93
|
+
wantedBox: number;
|
|
94
|
+
/**
|
|
95
|
+
* Largest logo box the code's error correction can spare: the plate may
|
|
96
|
+
* spoil at most a set share of the codewords each Reed–Solomon block
|
|
97
|
+
* repairs. Below 2 modules no plate is drawn.
|
|
98
|
+
*/
|
|
99
|
+
maxBox: number;
|
|
100
|
+
/** Logo box drawn: the wanted box, capped at `maxBox`; 0 with no plate */
|
|
101
|
+
box: number;
|
|
102
|
+
/** Logo and plate as drawn (centered on the code), or null with no plate */
|
|
103
|
+
plate: {
|
|
104
|
+
logoW: number;
|
|
105
|
+
logoH: number;
|
|
106
|
+
plateW: number;
|
|
107
|
+
plateH: number;
|
|
108
|
+
radius: number;
|
|
109
|
+
cx: number;
|
|
110
|
+
cy: number;
|
|
111
|
+
} | null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Logo QR "badge" sizes for `options` (as `renderQRArt` would draw them), or
|
|
115
|
+
* null when they don't render a badge. Editors can compare `box` with
|
|
116
|
+
* `wantedBox` to say the code is too small for a bigger logo.
|
|
117
|
+
*/
|
|
118
|
+
export declare function getQRArtBadgeLayout(options: QRArtRenderOptions): QRArtBadgeLayout | null;
|
|
119
|
+
export interface QRArtEyeColorOptions {
|
|
120
|
+
art: QRArt;
|
|
121
|
+
/** QR version (1–40) */
|
|
122
|
+
version: number;
|
|
123
|
+
/** Solid dark color (gradients: first stop) */
|
|
124
|
+
fgColor: string;
|
|
125
|
+
/** Solid light color (gradients: first stop) */
|
|
126
|
+
bgColor: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Logo QR: eye colors that match the logo, or null to keep the theme's.
|
|
130
|
+
* "blend" colors each eye's center from the logo color nearest to it (the
|
|
131
|
+
* frames keep the theme color); "badge" uses the logo's brand color for the
|
|
132
|
+
* frames and its accent for the centers. Colors stay dark enough to scan.
|
|
133
|
+
*/
|
|
134
|
+
export declare function getQRArtEyeColors(options: QRArtEyeColorOptions): Partial<Record<EyePosition, {
|
|
135
|
+
outer?: string;
|
|
136
|
+
inner?: string;
|
|
137
|
+
}>> | null;
|
|
138
|
+
//# sourceMappingURL=art.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"art.d.ts","sourceRoot":"","sources":["../../src/art.tsx"],"names":[],"mappings":"AAAA,iFAAiF;AAwBjF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAIL,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB/C,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAGzD,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA8ED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,UAAU,CAqDZ;AA8BD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,EACxC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,OAAO,CAAC,UAAU,CAAC,CA0CrB;AAED,gEAAgE;AAChE,wBAAgB,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AM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;QACX,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,IAAI,CAAC;CACV;AAyBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,kBAAkB,GAC1B,gBAAgB,GAAG,IAAI,CAMzB;AAmJD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,KAAK,CAAC;IACX,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,GAAG,IAAI,CA4DzE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: module geometry */
|
|
2
|
+
import type { JSX } from "react";
|
|
3
|
+
import type { BodyPattern, Modules } from "../types";
|
|
4
|
+
export declare const SHAPED_BODY_PATTERNS: readonly ["horizontal-line", "liquid", "liquid-horizontal", "liquid-vertical", "classy", "classy-rounded", "leaf", "plus", "hexagon", "star", "heart", "random-dots", "mosaic", "octagon"];
|
|
5
|
+
type ShapedBodyPattern = (typeof SHAPED_BODY_PATTERNS)[number];
|
|
6
|
+
export declare function isShapedBodyPattern(pattern: BodyPattern): pattern is ShapedBodyPattern;
|
|
7
|
+
/**
|
|
8
|
+
* Smallest `moduleScale` each pattern still decodes at (jsQR through the
|
|
9
|
+
* camera model at 4–9 px per module, dark and inverted), plus a 0.05 margin.
|
|
10
|
+
* Shapes that are already small barely shrink; unlisted patterns never do.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MODULE_SCALE_FLOOR: Partial<Record<BodyPattern, number>>;
|
|
13
|
+
/**
|
|
14
|
+
* `moduleScale` clamped to the supported range (1 when unset) and, with a
|
|
15
|
+
* `pattern`, to the smallest size that pattern still scans at.
|
|
16
|
+
*/
|
|
17
|
+
export declare function clampModuleScale(scale: number | undefined, pattern?: BodyPattern): number;
|
|
18
|
+
/** True for modules inside an alignment pattern (5×5, off the finders). */
|
|
19
|
+
export declare function alignmentMask(size: number): (x: number, y: number) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Renders the data modules for one of the `SHAPED_BODY_PATTERNS`. `scale`
|
|
22
|
+
* shrinks each module (or, for connected styles, the line width) around its
|
|
23
|
+
* center; alignment patterns keep full-size modules.
|
|
24
|
+
*/
|
|
25
|
+
export declare function renderShapedBody(modules: Modules, options: {
|
|
26
|
+
margin: number;
|
|
27
|
+
pixelSize: number;
|
|
28
|
+
pattern: ShapedBodyPattern;
|
|
29
|
+
scale?: number;
|
|
30
|
+
/** Decorative modules (a circle code's ring): no finders or alignment */
|
|
31
|
+
plain?: boolean;
|
|
32
|
+
}): JSX.Element[];
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=body-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body-patterns.d.ts","sourceRoot":"","sources":["../../src/body-patterns.tsx"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAsBrD,eAAO,MAAM,oBAAoB,4LAeU,CAAC;AAE5C,KAAK,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,GACnB,OAAO,IAAI,iBAAiB,CAE9B;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAqBnE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAMR;AAuBD,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAsB7E;AAgID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,GAAG,CAAC,OAAO,EAAE,CA6Gf"}
|
package/dist/src/codegen.d.ts
CHANGED
|
@@ -31,10 +31,10 @@ declare namespace qrcodegen {
|
|
|
31
31
|
private applyMask;
|
|
32
32
|
private getPenaltyScore;
|
|
33
33
|
private getAlignmentPatternPositions;
|
|
34
|
-
|
|
34
|
+
static getNumRawDataModules(ver: int): int;
|
|
35
35
|
private static getNumDataCodewords;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
static reedSolomonComputeDivisor(degree: int): Array<byte>;
|
|
37
|
+
static reedSolomonComputeRemainder(data: Readonly<Array<byte>>, divisor: Readonly<Array<byte>>): Array<byte>;
|
|
38
38
|
private static reedSolomonMultiply;
|
|
39
39
|
private finderPenaltyCountPatterns;
|
|
40
40
|
private finderPenaltyTerminateAndCount;
|
|
@@ -45,8 +45,8 @@ declare namespace qrcodegen {
|
|
|
45
45
|
private static readonly PENALTY_N2;
|
|
46
46
|
private static readonly PENALTY_N3;
|
|
47
47
|
private static readonly PENALTY_N4;
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
static readonly ECC_CODEWORDS_PER_BLOCK: Array<Array<int>>;
|
|
49
|
+
static readonly NUM_ERROR_CORRECTION_BLOCKS: Array<Array<int>>;
|
|
50
50
|
}
|
|
51
51
|
export class QrSegment {
|
|
52
52
|
readonly mode: QrSegment.Mode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/codegen.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,kBAAU,SAAS,CAAC;IAClB,KAAK,GAAG,GAAG,MAAM,CAAC;IAClB,KAAK,IAAI,GAAG,MAAM,CAAC;IACnB,KAAK,GAAG,GAAG,MAAM,CAAC;IAoBlB,MAAM,OAAO,MAAM;iBAoJC,OAAO,EAAE,GAAG;iBAGZ,oBAAoB,EAAE,MAAM,CAAC,GAAG;eA/IpC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,MAAM;eASjD,YAAY,CACxB,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAC3B,GAAG,EAAE,MAAM,CAAC,GAAG,GACd,MAAM;eAgBK,cAAc,CAC1B,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAChC,GAAG,EAAE,MAAM,CAAC,GAAG,EACf,UAAU,GAAE,GAAO,EACnB,UAAU,GAAE,GAAQ,EACpB,IAAI,GAAE,GAAQ,E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O/IEC 18004) */
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noBitwiseOperators: codeword bit placement */
|
|
3
|
+
import type { ErrorLevel } from "../types";
|
|
4
|
+
export interface CodewordMap {
|
|
5
|
+
version: number;
|
|
6
|
+
level: ErrorLevel;
|
|
7
|
+
/** Modules per side */
|
|
8
|
+
size: number;
|
|
9
|
+
/** Reed–Solomon blocks */
|
|
10
|
+
blocks: number;
|
|
11
|
+
/** Error correction codewords in each block */
|
|
12
|
+
eccPerBlock: number;
|
|
13
|
+
/** Codewords (data, then error correction) in each block */
|
|
14
|
+
blockLengths: number[];
|
|
15
|
+
/**
|
|
16
|
+
* Wrong codewords each block can repair: half its error correction
|
|
17
|
+
* codewords, less the few that ISO/IEC 18004 Table 9 keeps back for
|
|
18
|
+
* misdecode protection in versions 1–3.
|
|
19
|
+
*/
|
|
20
|
+
correctable: number;
|
|
21
|
+
/** Per module (y × size + x): block of its codeword, -1 if it carries none */
|
|
22
|
+
block: Int16Array;
|
|
23
|
+
/** Per module: index of its codeword in that block, -1 if none */
|
|
24
|
+
codeword: Int16Array;
|
|
25
|
+
/** Per module: bit of that codeword (7 = most significant), -1 if none */
|
|
26
|
+
bit: Int8Array;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The (block, codeword, bit) every module of a version `version`, level
|
|
30
|
+
* `level` code carries. The mask doesn't move codewords, so one map serves
|
|
31
|
+
* all eight masks.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCodewordMap(version: number, level: ErrorLevel): CodewordMap;
|
|
34
|
+
/**
|
|
35
|
+
* Codewords per block that have at least one module among `modules`
|
|
36
|
+
* (indexes y × size + x). Each counts as one error: a covered module reads
|
|
37
|
+
* wrong about half the time, and one wrong bit spoils the whole codeword.
|
|
38
|
+
*/
|
|
39
|
+
export declare function damagedCodewords(map: CodewordMap, modules: Iterable<number>): number[];
|
|
40
|
+
//# sourceMappingURL=codeword-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeword-map.d.ts","sourceRoot":"","sources":["../../src/codeword-map.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,kFAAkF;AASlF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAM3C,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC;IAClB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,KAAK,EAAE,UAAU,CAAC;IAClB,kEAAkE;IAClE,QAAQ,EAAE,UAAU,CAAC;IACrB,0EAA0E;IAC1E,GAAG,EAAE,SAAS,CAAC;CAChB;AA4KD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,UAAU,GAChB,WAAW,CAoBb;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GACxB,MAAM,EAAE,CAeV"}
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -29,9 +29,10 @@ export declare const DEFAULT_EYECOLOR = "#000000";
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const DEFAULT_DOTCOLOR = "#000000";
|
|
31
31
|
/**
|
|
32
|
-
* Default margin around the QR code.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* Default margin (quiet zone) around the QR code, in modules.
|
|
33
|
+
* Defaults to 0 so the code fills its box; the QR spec recommends a 4-module
|
|
34
|
+
* light quiet zone, so set `margin` (or give the container light padding)
|
|
35
|
+
* when the code sits on a busy or dark background.
|
|
35
36
|
*/
|
|
36
37
|
export declare const DEFAULT_MARGIN = 0;
|
|
37
38
|
/**
|
|
@@ -45,8 +46,4 @@ export declare const QR_LEVELS: readonly ErrorLevel[];
|
|
|
45
46
|
* get an explicit height or width, I'd rather default to something than throw.
|
|
46
47
|
*/
|
|
47
48
|
export declare const DEFAULT_IMG_SCALE = 0.1;
|
|
48
|
-
/**
|
|
49
|
-
* Default logo URL for QR codes
|
|
50
|
-
*/
|
|
51
|
-
export declare const FLAM_QR_LOGO = "https://qrdx.dev/logo.png";
|
|
52
49
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAKpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,UAAgB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAKpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,UAAgB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,UAAU,EAAkC,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC"}
|
package/dist/src/corner-dot.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
2
|
import type { CornerEyeDotPattern } from "../types/corner-dot";
|
|
3
|
+
import type { EyeCorner } from "./corner-eye";
|
|
3
4
|
/**
|
|
4
5
|
* Generate corner dot pattern based on type
|
|
5
6
|
* @param cx - Center X coordinate
|
|
6
7
|
* @param cy - Center Y coordinate
|
|
7
8
|
* @param radius - Radius of the dot
|
|
8
9
|
* @param pattern - Pattern type for the corner dot
|
|
10
|
+
* @param corner - Which finder this is (leaf and drop dots face outward)
|
|
9
11
|
* @returns JSX element representing the pattern
|
|
10
12
|
*/
|
|
11
|
-
export declare function generateCornerDotPath(cx: number, cy: number, radius: number, pattern?: CornerEyeDotPattern): JSX.Element;
|
|
13
|
+
export declare function generateCornerDotPath(cx: number, cy: number, radius: number, pattern?: CornerEyeDotPattern, corner?: EyeCorner): JSX.Element;
|
|
12
14
|
//# sourceMappingURL=corner-dot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corner-dot.d.ts","sourceRoot":"","sources":["../../src/corner-dot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"corner-dot.d.ts","sourceRoot":"","sources":["../../src/corner-dot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAgB9C;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAA8B,EACvC,MAAM,GAAE,SAAsB,GAC7B,GAAG,CAAC,OAAO,CAgSb"}
|
package/dist/src/corner-eye.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { CornerEyePattern } from "../types/corner-eye";
|
|
2
|
+
/** Which finder an eye is drawn for (some shapes face the code's corners). */
|
|
3
|
+
export type EyeCorner = "top-left" | "top-right" | "bottom-left";
|
|
2
4
|
/**
|
|
3
5
|
* Generate corner square path based on pattern type
|
|
4
6
|
* @param offsetX - X offset for the corner
|
|
5
7
|
* @param offsetY - Y offset for the corner
|
|
6
8
|
* @param size - Size of the corner pattern
|
|
7
9
|
* @param pattern - Pattern type for the corner eye
|
|
8
|
-
* @
|
|
10
|
+
* @param corner - Which finder this is (leaf and drop eyes face outward)
|
|
11
|
+
* @returns SVG path string for the pattern (drawn with fill-rule evenodd)
|
|
9
12
|
*/
|
|
10
|
-
export declare function generateCornerSquarePath(offsetX: number, offsetY: number, size: number, pattern: CornerEyePattern): string;
|
|
13
|
+
export declare function generateCornerSquarePath(offsetX: number, offsetY: number, size: number, pattern: CornerEyePattern, corner?: EyeCorner): string;
|
|
11
14
|
//# sourceMappingURL=corner-eye.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corner-eye.d.ts","sourceRoot":"","sources":["../../src/corner-eye.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"corner-eye.d.ts","sourceRoot":"","sources":["../../src/corner-eye.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAS5D,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;AAgcjE;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,EACzB,MAAM,GAAE,SAAsB,GAC7B,MAAM,CAwCR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detection.d.ts","sourceRoot":"","sources":["../../src/detection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detection.d.ts","sourceRoot":"","sources":["../../src/detection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,WAAW,SAAS,EACpB,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,UAAU,MAAM,SA2BjB,CAAC;AAkHF,eAAO,MAAM,eAAe,GAC1B,eAAe,gBAAgB,EAC/B,OAAO,MAAM,EACb,wBAAsB,iBA2CvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,gBAAgB,EAC5B,WAAW,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvC,QAAQ,EAAE,MAAM,QAsDjB"}
|
package/dist/src/download.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { QRProps } from "../types";
|
|
2
|
-
|
|
3
|
-
export type
|
|
2
|
+
/** "eps" is vector PostScript: `size.width` becomes points (72 per inch). */
|
|
3
|
+
export type DownloadFormat = "png" | "jpg" | "svg" | "pdf" | "eps";
|
|
4
|
+
export interface DownloadSize {
|
|
4
5
|
width: number;
|
|
5
6
|
height: number;
|
|
6
|
-
}
|
|
7
|
+
}
|
|
7
8
|
export declare const PRESET_SIZES: Record<string, DownloadSize>;
|
|
8
|
-
export
|
|
9
|
+
export interface DownloadOptions {
|
|
9
10
|
format: DownloadFormat;
|
|
10
11
|
size: DownloadSize;
|
|
11
12
|
filename?: string;
|
|
12
|
-
}
|
|
13
|
+
}
|
|
13
14
|
/**
|
|
14
15
|
* Validates if a size value is within acceptable bounds
|
|
15
16
|
*/
|
|
@@ -17,6 +18,22 @@ export declare function validateSize(width: number, height: number): {
|
|
|
17
18
|
isValid: boolean;
|
|
18
19
|
error?: string;
|
|
19
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Returns props rendered at `size`. A logo laid out for the props' own `size`
|
|
23
|
+
* (as `getQRData` does on a 1024px canvas) is scaled along with the code.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withQRSize(qrProps: QRProps, size: number): QRProps;
|
|
26
|
+
/**
|
|
27
|
+
* Downloads a file to the user's device
|
|
28
|
+
*/
|
|
29
|
+
export declare function downloadFile(dataUrl: string, filename: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* The default file name of a download: for PNG and JPG (and the image a
|
|
32
|
+
* PDF holds) the exact pixel size of what is saved, which a frame makes
|
|
33
|
+
* bigger than the code (a 400 px code in a bottom banner is 496 × 568);
|
|
34
|
+
* SVG and EPS have no pixel size and name none.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getDownloadFilename(format: DownloadFormat, size: DownloadSize, frame?: QRProps["frame"]): string;
|
|
20
37
|
/**
|
|
21
38
|
* Downloads a QR code with the specified options
|
|
22
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/download.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/download.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMxC,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAOrD,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CA0BA;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAoBlE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAO7D;AAgCD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,YAAY,EAClB,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GACvB,MAAM,CAQR;AAoHD;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC,CAwCf;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,MAAM,CAAC,CA8BjB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE,YAA4D,GACjE,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAGpE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: PostScript output */
|
|
2
|
+
/** biome-ignore-all lint/suspicious/noBitwiseOperators: ASCII85 and JPEG parsing */
|
|
3
|
+
import type { QRProps } from "../types";
|
|
4
|
+
import { type PrintColorMode } from "./print";
|
|
5
|
+
export interface EPSOptions {
|
|
6
|
+
/** "cmyk" writes naive CMYK colors, see `rgbToCmyk` (default "rgb") */
|
|
7
|
+
colorMode?: PrintColorMode;
|
|
8
|
+
/** Width of the QR code itself in millimetres (default 50). A frame adds to it. */
|
|
9
|
+
sizeMm?: number;
|
|
10
|
+
/** Bleed on every side, in millimetres (default 0, at most 20) */
|
|
11
|
+
bleedMm?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface SVGToEPSOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Output width in PostScript points (72 per inch); the height follows the
|
|
16
|
+
* SVG's aspect ratio. Defaults to the SVG's own width (1 unit = 1 point).
|
|
17
|
+
*/
|
|
18
|
+
width?: number;
|
|
19
|
+
colorMode?: PrintColorMode;
|
|
20
|
+
/** Bleed on every side, in points (default 0) */
|
|
21
|
+
bleed?: number;
|
|
22
|
+
/**
|
|
23
|
+
* CSS color that fills the bleed area, or `url(#id)` of a gradient in the
|
|
24
|
+
* SVG to continue it as the root's user space places it (default: none)
|
|
25
|
+
*/
|
|
26
|
+
bleedColor?: string | null;
|
|
27
|
+
title?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The code's background color: see-through paint is flattened over it
|
|
30
|
+
* (on white paper), since PostScript has no transparency. Default white.
|
|
31
|
+
*/
|
|
32
|
+
background?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Converts SVG markup (as this library renders it) to an Encapsulated
|
|
36
|
+
* PostScript file: vector paths for modules, eyes and frames, Helvetica for
|
|
37
|
+
* frame text (Latin-1 only), no transparency (see-through colors are mixed
|
|
38
|
+
* with `background`, the background itself with white paper). Linear and radial gradient
|
|
39
|
+
* fills become smooth shadings clipped to each shape (`shfill`, which makes
|
|
40
|
+
* the file LanguageLevel 3); gradient strokes and text use their first color.
|
|
41
|
+
* PNG and JPEG logos are embedded; other logo formats are redrawn as PNG in
|
|
42
|
+
* the browser and left out elsewhere.
|
|
43
|
+
*/
|
|
44
|
+
export declare function svgToEPS(svg: string, options?: SVGToEPSOptions): Promise<string>;
|
|
45
|
+
/** Why EPS refuses a design with an image fill (see `hasImageFill`). */
|
|
46
|
+
export declare const EPS_IMAGE_FILL_REASON = "EPS can't carry image fills: PostScript has no transparency and would repeat the picture for every dot. Download PDF, SVG or PNG instead.";
|
|
47
|
+
/** True when a color in the props is an image fill. */
|
|
48
|
+
export declare function hasImageFill(props: QRProps): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Renders a vector EPS for print and design tools (Illustrator, InDesign,
|
|
51
|
+
* CorelDRAW): the QR code is `sizeMm` wide (default 50 mm), plus any frame
|
|
52
|
+
* and bleed. See `svgToEPS` for what is converted and what is left out.
|
|
53
|
+
* Throws `EPS_IMAGE_FILL_REASON` for a design with an image fill.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getQRAsEPS(props: QRProps, options?: EPSOptions): Promise<string>;
|
|
56
|
+
/** EPS text as a `data:application/postscript` URL (EPS output is 7-bit ASCII). */
|
|
57
|
+
export declare function epsToDataUrl(eps: string): string;
|
|
58
|
+
/** Downloads `getQRAsEPS` output (browser only). */
|
|
59
|
+
export declare function downloadPrintEPS(props: QRProps, options?: EPSOptions & {
|
|
60
|
+
filename?: string;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
//# sourceMappingURL=eps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eps.d.ts","sourceRoot":"","sources":["../../src/eps.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,oFAAoF;AACpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAyC9D,MAAM,WAAW,UAAU;IACzB,uEAAuE;IACvE,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAmcD;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CA+FjB;AAED,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,8IAC2G,CAAC;AAE9I,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcpD;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,oDAAoD;AACpD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,UAAU,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: icon geometry */
|
|
2
|
+
import type { FrameSpecIcon } from "../types/frame-spec";
|
|
3
|
+
/** Side of the box icons are drawn in. */
|
|
4
|
+
export declare const FRAME_ICON_BOX = 24;
|
|
5
|
+
export interface FrameIconPath {
|
|
6
|
+
d: string;
|
|
7
|
+
fillRule: "nonzero" | "evenodd";
|
|
8
|
+
}
|
|
9
|
+
/** Path data of a built-in icon, in a 24 × 24 box. */
|
|
10
|
+
export declare function getFrameIconPath(icon: FrameSpecIcon): FrameIconPath;
|
|
11
|
+
//# sourceMappingURL=frame-icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-icons.d.ts","sourceRoot":"","sources":["../../src/frame-icons.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAOhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAWzD,0CAA0C;AAC1C,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,SAAS,GAAG,SAAS,CAAC;CACjC;AAySD,sDAAsD;AACtD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAEnE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: import limits */
|
|
2
|
+
import { type FrameSpec } from "../types/frame-spec";
|
|
3
|
+
export declare const FRAME_IMPORT_LIMITS: {
|
|
4
|
+
/** Largest SVG accepted, in UTF-8 bytes */
|
|
5
|
+
readonly maxBytes: 200000;
|
|
6
|
+
readonly maxElements: 500;
|
|
7
|
+
readonly maxDepth: 16;
|
|
8
|
+
/** Segments read from the SVG, before simplifying */
|
|
9
|
+
readonly maxInputSegments: 4000;
|
|
10
|
+
/** Distinct fill colors kept (closer ones are merged) */
|
|
11
|
+
readonly maxColors: 8;
|
|
12
|
+
/** The artboard's longer side, in spec units */
|
|
13
|
+
readonly artboardSide: 1000;
|
|
14
|
+
/** Decimals kept in the spec's path data */
|
|
15
|
+
readonly decimals: 1;
|
|
16
|
+
/** Default light padding around the code, as a share of its size */
|
|
17
|
+
readonly padding: 0.06;
|
|
18
|
+
};
|
|
19
|
+
export interface FrameImportWarning {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
count: number;
|
|
23
|
+
}
|
|
24
|
+
export interface FrameImportColor {
|
|
25
|
+
color: string;
|
|
26
|
+
/** What the color became: a theme token or a fixed color */
|
|
27
|
+
ref: "frame" | "accent" | "fixed";
|
|
28
|
+
/** Shapes painted with it */
|
|
29
|
+
shapes: number;
|
|
30
|
+
}
|
|
31
|
+
export interface FrameImportOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Where the code goes, in the SVG's own units (its viewBox). By default a
|
|
34
|
+
* rect with the id "qr" (or "qr-code", "qrdx-qr") marks it and isn't
|
|
35
|
+
* drawn; without one, the code is centered at 60% of the shorter side.
|
|
36
|
+
*/
|
|
37
|
+
qr?: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
size: number;
|
|
41
|
+
};
|
|
42
|
+
/** Light padding around the code, as a share of its size (default 0.06) */
|
|
43
|
+
padding?: number;
|
|
44
|
+
}
|
|
45
|
+
export type FrameImportResult = {
|
|
46
|
+
ok: true;
|
|
47
|
+
spec: FrameSpec;
|
|
48
|
+
warnings: FrameImportWarning[];
|
|
49
|
+
palette: FrameImportColor[];
|
|
50
|
+
} | {
|
|
51
|
+
ok: false;
|
|
52
|
+
error: string;
|
|
53
|
+
warnings: FrameImportWarning[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Converts SVG markup into a frame spec. Never throws: problems come back
|
|
57
|
+
* as `{ ok: false, error }`, and everything that was dropped or changed is
|
|
58
|
+
* listed in `warnings`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function importFrameSvg(svg: string, options?: FrameImportOptions): FrameImportResult;
|
|
61
|
+
//# sourceMappingURL=frame-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-import.d.ts","sourceRoot":"","sources":["../../src/frame-import.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAoBhE,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,qBAAqB,CAAC;AAwB7B,eAAO,MAAM,mBAAmB;IAC9B,2CAA2C;;;;IAI3C,qDAAqD;;IAErD,yDAAyD;;IAEzD,gDAAgD;;IAEhD,4CAA4C;;IAE5C,oEAAoE;;CAE5D,CAAC;AAEX,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,GAAG,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClC,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,EAAE,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAAC;AAy1BjE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CAyOnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: frame geometry */
|
|
2
|
+
import type { ColorConfig } from "../types/color";
|
|
3
|
+
import { type FrameSpec, type QRCustomFrame } from "../types/frame-spec";
|
|
4
|
+
import type { FrameLayout } from "./frame";
|
|
5
|
+
/** Thrown when a custom frame's spec doesn't validate. */
|
|
6
|
+
export declare class FrameSpecError extends Error {
|
|
7
|
+
readonly issues: string[];
|
|
8
|
+
constructor(issues: string[]);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validates `spec` with `frameSpecSchema` (every limit applies) and returns
|
|
12
|
+
* the parsed copy. Throws a `FrameSpecError` listing the problems.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveFrameSpec(spec: unknown): FrameSpec;
|
|
15
|
+
/** Light gap around the code as a share of its width (the plate's padding). */
|
|
16
|
+
export declare function getFrameSpecGapRatio(spec: unknown): number;
|
|
17
|
+
/**
|
|
18
|
+
* Layout of a custom frame for a code of `size` pixels: the spec scaled so
|
|
19
|
+
* its QR box is `size` wide, colors resolved from the frame options (then
|
|
20
|
+
* the spec's defaults), labels filled from `text` / `secondaryText`.
|
|
21
|
+
* Throws a `FrameSpecError` when the spec is invalid.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCustomFrameLayout(size: number, frame: QRCustomFrame, bgColor?: ColorConfig): FrameLayout;
|
|
24
|
+
//# sourceMappingURL=frame-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-spec.d.ts","sourceRoot":"","sources":["../../src/frame-spec.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAMjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAGL,KAAK,SAAS,EAOd,KAAK,aAAa,EAEnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAc,WAAW,EAAc,MAAM,SAAS,CAAC;AAoBnE,0DAA0D;AAC1D,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEd,MAAM,EAAE,MAAM,EAAE;CAK7B;AAKD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAwBzD;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAG1D;AAyXD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE,WAAW,GACpB,WAAW,CAwCb"}
|