qrdx 0.0.54 → 0.0.55

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.
Files changed (113) hide show
  1. package/README.md +1 -1
  2. package/dist/core.js +7 -7
  3. package/dist/core.js.map +1 -1
  4. package/dist/core.mjs +7 -7
  5. package/dist/core.mjs.map +1 -1
  6. package/dist/element.browser.mjs +6 -67
  7. package/dist/element.browser.mjs.map +1 -1
  8. package/dist/index.js +7 -7
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +7 -7
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/qr-code-canvas.js +1 -1
  13. package/dist/qr-code-canvas.js.map +1 -1
  14. package/dist/qr-code-canvas.mjs +1 -1
  15. package/dist/qr-code-canvas.mjs.map +1 -1
  16. package/dist/schemas.js +2 -0
  17. package/dist/schemas.js.map +1 -0
  18. package/dist/schemas.mjs +2 -0
  19. package/dist/schemas.mjs.map +1 -0
  20. package/dist/src/art.d.ts +1 -1
  21. package/dist/src/art.d.ts.map +1 -1
  22. package/dist/src/engine.d.ts +2 -1
  23. package/dist/src/engine.d.ts.map +1 -1
  24. package/dist/src/eps.d.ts.map +1 -1
  25. package/dist/src/frame-import.d.ts +1 -1
  26. package/dist/src/frame-import.d.ts.map +1 -1
  27. package/dist/src/frame-spec.d.ts +5 -4
  28. package/dist/src/frame-spec.d.ts.map +1 -1
  29. package/dist/src/frame.d.ts +1 -1
  30. package/dist/src/frame.d.ts.map +1 -1
  31. package/dist/src/frames/builtin.d.ts +1 -1
  32. package/dist/src/frames/builtin.d.ts.map +1 -1
  33. package/dist/src/qr-outline.d.ts +1 -2
  34. package/dist/src/qr-outline.d.ts.map +1 -1
  35. package/dist/src/qr-shape.d.ts +1 -1
  36. package/dist/src/qr-shape.d.ts.map +1 -1
  37. package/dist/src/silhouette.d.ts +1 -2
  38. package/dist/src/silhouette.d.ts.map +1 -1
  39. package/dist/src/template/dot-ring-layout.d.ts +26 -3
  40. package/dist/src/template/dot-ring-layout.d.ts.map +1 -1
  41. package/dist/src/template/dot-ring.d.ts +22 -4
  42. package/dist/src/template/dot-ring.d.ts.map +1 -1
  43. package/dist/src/utils.d.ts +1 -1
  44. package/dist/src/utils.d.ts.map +1 -1
  45. package/dist/types/art.d.ts +1 -18
  46. package/dist/types/art.d.ts.map +1 -1
  47. package/dist/types/color-helpers.d.ts +26 -0
  48. package/dist/types/color-helpers.d.ts.map +1 -0
  49. package/dist/types/color.d.ts +1 -24
  50. package/dist/types/color.d.ts.map +1 -1
  51. package/dist/types/constants.d.ts +97 -0
  52. package/dist/types/constants.d.ts.map +1 -0
  53. package/dist/types/corner-dot.d.ts +2 -12
  54. package/dist/types/corner-dot.d.ts.map +1 -1
  55. package/dist/types/corner-eye.d.ts +2 -11
  56. package/dist/types/corner-eye.d.ts.map +1 -1
  57. package/dist/types/frame-spec-parse.d.ts +21 -0
  58. package/dist/types/frame-spec-parse.d.ts.map +1 -0
  59. package/dist/types/frame-spec-rules.d.ts +95 -0
  60. package/dist/types/frame-spec-rules.d.ts.map +1 -0
  61. package/dist/types/frame-spec.d.ts +2 -83
  62. package/dist/types/frame-spec.d.ts.map +1 -1
  63. package/dist/types/frame.d.ts +1 -8
  64. package/dist/types/frame.d.ts.map +1 -1
  65. package/dist/types/image-pattern.d.ts +1 -1
  66. package/dist/types/image-pattern.d.ts.map +1 -1
  67. package/dist/types/index.d.ts +3 -22
  68. package/dist/types/index.d.ts.map +1 -1
  69. package/dist/types/index.js +2 -2
  70. package/dist/types/index.js.map +1 -1
  71. package/dist/types/index.mjs +2 -2
  72. package/dist/types/index.mjs.map +1 -1
  73. package/dist/types/plain.d.ts +17 -0
  74. package/dist/types/plain.d.ts.map +1 -0
  75. package/dist/types/qr.d.ts +2 -46
  76. package/dist/types/qr.d.ts.map +1 -1
  77. package/dist/types/schemas.d.ts +12 -0
  78. package/dist/types/schemas.d.ts.map +1 -0
  79. package/dist/vanilla.browser.mjs +28 -28
  80. package/dist/vanilla.browser.mjs.map +1 -1
  81. package/package.json +1 -1
  82. package/src/art.tsx +3 -6
  83. package/src/body-patterns.tsx +1 -1
  84. package/src/engine.ts +53 -1
  85. package/src/eps.ts +6 -1
  86. package/src/frame-import.ts +7 -6
  87. package/src/frame-spec.ts +17 -23
  88. package/src/frame.tsx +3 -2
  89. package/src/frames/builtin.ts +2 -5
  90. package/src/helpers.ts +1 -1
  91. package/src/qr-outline.ts +2 -2
  92. package/src/qr-shape.ts +2 -5
  93. package/src/scan-score.ts +2 -2
  94. package/src/silhouette.ts +2 -2
  95. package/src/template/dot-ring-layout.ts +281 -15
  96. package/src/template/dot-ring.tsx +27 -8
  97. package/src/utils/print-shared.ts +1 -1
  98. package/src/utils.tsx +6 -5
  99. package/types/art.ts +10 -20
  100. package/types/color-helpers.ts +132 -0
  101. package/types/color.ts +9 -122
  102. package/types/constants.ts +222 -0
  103. package/types/corner-dot.ts +8 -40
  104. package/types/corner-eye.ts +2 -31
  105. package/types/frame-spec-parse.ts +683 -0
  106. package/types/frame-spec-rules.ts +645 -0
  107. package/types/frame-spec.ts +38 -635
  108. package/types/frame.ts +14 -34
  109. package/types/image-pattern.ts +2 -26
  110. package/types/index.ts +6 -162
  111. package/types/plain.ts +117 -0
  112. package/types/qr.ts +29 -51
  113. package/types/schemas.ts +62 -0
@@ -15,7 +15,7 @@ import {
15
15
  DEFAULT_LETTER_SPACING,
16
16
  DEFAULT_TEXT,
17
17
  dotRingDots,
18
- dotRingLetters,
18
+ dotRingText,
19
19
  dotsClearOfCode,
20
20
  RING_INNER_RADIUS,
21
21
  RING_PATH,
@@ -26,10 +26,22 @@ import {
26
26
  export interface DotRingProps {
27
27
  /**
28
28
  * Text set along the ring. Defaults to "Scan the QR code" four times
29
- * round; `""` leaves the ring empty. Letters that don't fit around the
30
- * ring are left out.
29
+ * round; `""` leaves the ring empty. Text too long for the ring gets
30
+ * tighter letter spacing, then a smaller font (down to half of
31
+ * `fontSize`'s default); it never runs into its own start. Past that,
32
+ * text that repeats a phrase keeps as many whole copies as fit, and other
33
+ * text is cut after the last whole word that fits and ends with "…".
31
34
  */
32
35
  customText?: string;
36
+ /**
37
+ * "repeat" fills the ring: the phrase is repeated as many times as fit,
38
+ * with the spacing evened out so the copies close the ring with the same
39
+ * gap as between them. Give the phrase once ("Read the docs *"); text
40
+ * that already repeats a phrase ("A * A * A *") is read as that phrase.
41
+ * Default "none": the text is set once, centered over the top (or along
42
+ * the bottom).
43
+ */
44
+ textFill?: "none" | "repeat";
33
45
  /** "top" (default): centered over the top, reading clockwise. "bottom": centered along the bottom, reading left to right. */
34
46
  textPosition?: "top" | "bottom";
35
47
  /** Turns the text around the center, in degrees clockwise (default 0). */
@@ -40,9 +52,15 @@ export interface DotRingProps {
40
52
  fontFamily?: string;
41
53
  /** Font weight (default 900). */
42
54
  fontWeight?: number | string;
43
- /** Font size in the template's 593-unit drawing, where the code is 300 across (default 32). */
55
+ /**
56
+ * Font size in the template's 593-unit drawing, where the code is 300
57
+ * across (default 32). Long text may be drawn smaller (see `customText`).
58
+ */
44
59
  fontSize?: number;
45
- /** Extra space between letters, in the same units (default 3.5). */
60
+ /**
61
+ * Extra space between letters, in the same units (default 3.5). Long text
62
+ * and `textFill: "repeat"` adjust it to fit the ring.
63
+ */
46
64
  fontLetterSpacing?: number;
47
65
  /** Color of the ring (default: the code's `fgColor`). */
48
66
  outerCircleColor?: string;
@@ -82,11 +100,12 @@ export const DotRing: TemplateDefinition<DotRingProps> = {
82
100
  const fontSize = requestedSize > 0 ? requestedSize : DEFAULT_FONT_SIZE;
83
101
  const text =
84
102
  typeof props?.customText === "string" ? props.customText : DEFAULT_TEXT;
85
- const letters = dotRingLetters(text, {
103
+ const ring = dotRingText(text, {
86
104
  fontSize,
87
105
  letterSpacing: finite(props?.fontLetterSpacing, DEFAULT_LETTER_SPACING),
88
106
  position: props?.textPosition === "bottom" ? "bottom" : "top",
89
107
  rotation: finite(props?.textRotation, 0),
108
+ fill: props?.textFill === "repeat" ? "repeat" : "none",
90
109
  });
91
110
  const textColor = props?.textColor || "#ffffff";
92
111
  const fontFamily = props?.fontFamily || FRAME_FONT_FAMILY;
@@ -142,11 +161,11 @@ export const DotRing: TemplateDefinition<DotRingProps> = {
142
161
  screen reader, so they're hidden from it */}
143
162
  {/* biome-ignore lint/a11y/noAriaHiddenOnFocusable: an SVG <g> can't take focus */}
144
163
  <g aria-hidden="true">
145
- {letters.map((letter, index) => (
164
+ {ring.letters.map((letter, index) => (
146
165
  <text
147
166
  fill={textColor}
148
167
  fontFamily={fontFamily}
149
- fontSize={fontSize}
168
+ fontSize={ring.fontSize}
150
169
  fontWeight={fontWeight}
151
170
  key={index}
152
171
  textAnchor="middle"
@@ -1,5 +1,5 @@
1
1
  import type { QRProps } from "../../types";
2
- import { isGradient } from "../../types/color";
2
+ import { isGradient } from "../../types/color-helpers";
3
3
  import { DEFAULT_BGCOLOR, DEFAULT_SIZE } from "../constants";
4
4
  import { withQRSize } from "../download";
5
5
  import { getQRAsSVGDataUri } from "../export";
package/src/utils.tsx CHANGED
@@ -14,12 +14,13 @@ import type {
14
14
  RadialGradient,
15
15
  TemplateConfig,
16
16
  } from "../types";
17
- import { isGradient, isImagePaint, normalizeColorConfig } from "../types/color";
18
17
  import {
19
- AUTO_LEVEL_LOGO_COVERAGE,
20
- type EyePosition,
21
- type QRCodeShape,
22
- } from "../types/qr";
18
+ isGradient,
19
+ isImagePaint,
20
+ normalizeColorConfig,
21
+ } from "../types/color-helpers";
22
+ import { AUTO_LEVEL_LOGO_COVERAGE } from "../types/constants";
23
+ import type { EyePosition, QRCodeShape } from "../types/qr";
23
24
  import { getQRArtEyeColors, isQRArtActive, renderQRArt } from "./art";
24
25
  import {
25
26
  alignmentMask,
package/types/art.ts CHANGED
@@ -1,35 +1,25 @@
1
1
  import { z } from "zod";
2
+ import {
3
+ QR_ART_MAX_SAMPLE_SIZE,
4
+ QR_ART_MODES,
5
+ QR_ART_VARIANTS,
6
+ } from "./constants";
2
7
 
3
- /**
4
- * Art modes blend a picture into the code itself (vector output, no AI):
5
- * - "logo" (Logo QR): the logo, traced into crisp vector shapes, either fills
6
- * the code under a fine dot screen ("blend") or sits on a rounded plate in
7
- * the middle of a code tinted with its colors ("badge").
8
- * - "halftone" (Image QR): the photo shows through every module around a
9
- * small center dot that keeps the module's dark/light value, in full color
10
- * ("color") or as an error-diffused black-and-white halftone ("mono").
11
- * Finder, alignment and format patterns always stay crisp.
12
- */
13
- export const QR_ART_MODES = ["logo", "halftone"] as const;
8
+ export {
9
+ QR_ART_MAX_SAMPLE_SIZE,
10
+ QR_ART_MODES,
11
+ QR_ART_VARIANTS,
12
+ } from "./constants";
14
13
 
15
14
  export const qrArtModeSchema = z.enum(QR_ART_MODES);
16
15
  export type QRArtMode = z.infer<typeof qrArtModeSchema>;
17
16
 
18
- /** Looks within each mode; the first one is the mode's default. */
19
- export const QR_ART_VARIANTS = {
20
- logo: ["blend", "badge"],
21
- halftone: ["color", "mono"],
22
- } as const satisfies Record<QRArtMode, readonly string[]>;
23
-
24
17
  export const qrArtVariantSchema = z.enum([
25
18
  ...QR_ART_VARIANTS.logo,
26
19
  ...QR_ART_VARIANTS.halftone,
27
20
  ]);
28
21
  export type QRArtVariant = z.infer<typeof qrArtVariantSchema>;
29
22
 
30
- /** Largest side of an art sample grid, in pixels. */
31
- export const QR_ART_MAX_SAMPLE_SIZE = 192;
32
-
33
23
  const base64Length = (bytes: number) => Math.ceil(bytes / 3) * 4;
34
24
 
35
25
  /**
@@ -0,0 +1,132 @@
1
+ // Color helpers, without zod: the engine draws with these, so rendering a
2
+ // code never loads zod. The color schemas and types are in color.ts, which
3
+ // re-exports these.
4
+ import type {
5
+ ColorConfig,
6
+ Gradient,
7
+ ImagePaint,
8
+ ImagePosition,
9
+ SolidColor,
10
+ } from "./color";
11
+
12
+ /**
13
+ * Helper to normalize color config to object format
14
+ */
15
+ export function normalizeColorConfig(
16
+ color: ColorConfig | undefined,
17
+ fallback = "#000000"
18
+ ): SolidColor | Gradient | ImagePaint {
19
+ if (!color) {
20
+ return { type: "solid", color: fallback };
21
+ }
22
+ if (typeof color === "string") {
23
+ return { type: "solid", color };
24
+ }
25
+ return color;
26
+ }
27
+
28
+ /**
29
+ * Helper to check if color is gradient
30
+ */
31
+ export function isGradient(color: ColorConfig | undefined): color is Gradient {
32
+ if (!color || typeof color === "string") {
33
+ return false;
34
+ }
35
+ return (
36
+ color.type === "linear" ||
37
+ color.type === "radial" ||
38
+ color.type === "angular"
39
+ );
40
+ }
41
+
42
+ /** True for an image fill. */
43
+ export function isImagePaint(
44
+ color: ColorConfig | undefined
45
+ ): color is ImagePaint {
46
+ return typeof color === "object" && color !== null && color.type === "image";
47
+ }
48
+
49
+ /**
50
+ * Helper to get a solid color string from any ColorConfig
51
+ * For gradients, returns the first stop color; for an image fill, its
52
+ * underlay (or `fallback`)
53
+ */
54
+ export function getColorString(
55
+ color: ColorConfig | undefined,
56
+ fallback = "#000000"
57
+ ): string {
58
+ const normalized = normalizeColorConfig(color, fallback);
59
+ if (normalized.type === "solid") {
60
+ return normalized.color;
61
+ }
62
+ if (normalized.type === "image") {
63
+ return normalized.underlay || fallback;
64
+ }
65
+ return normalized.stops[0]?.color || fallback;
66
+ }
67
+
68
+ /** CSS `background-position` for an image fill's position. */
69
+ export function imagePositionCss(position: ImagePosition = "center"): string {
70
+ const [first, second] = position.split("-") as [string, string | undefined];
71
+ if (position === "center") {
72
+ return "center";
73
+ }
74
+ if (second) {
75
+ return `${second} ${first}`;
76
+ }
77
+ return first === "top" || first === "bottom"
78
+ ? `center ${first}`
79
+ : `${first} center`;
80
+ }
81
+
82
+ /**
83
+ * CSS `background` for a color config, for swatches and previews: the color
84
+ * itself, or a CSS gradient that matches how the engine draws it (a linear
85
+ * angle of 0 runs left to right, as in the QR code).
86
+ */
87
+ export function getNormalizedColor(
88
+ color: ColorConfig | string | undefined
89
+ ): string {
90
+ if (!color) {
91
+ return "#000000";
92
+ }
93
+
94
+ if (typeof color === "string") {
95
+ return color;
96
+ }
97
+
98
+ const normalized = normalizeColorConfig(color);
99
+ if (normalized.type === "solid") {
100
+ return normalized.color;
101
+ }
102
+
103
+ if (normalized.type === "image") {
104
+ const size =
105
+ normalized.fit === "tile"
106
+ ? `${25 * (normalized.scale ?? 1)}% auto`
107
+ : (normalized.scale ?? 1) === 1
108
+ ? normalized.fit === "contain"
109
+ ? "contain"
110
+ : "cover"
111
+ : `${100 * (normalized.scale ?? 1)}% auto`;
112
+ const repeat = normalized.fit === "tile" ? "repeat" : "no-repeat";
113
+ const url = `url("${normalized.src.replace(/"/g, "%22")}")`;
114
+ return `${url} ${imagePositionCss(normalized.position)} / ${size} ${repeat}, ${normalized.underlay ?? "transparent"}`;
115
+ }
116
+
117
+ const sortedStops = [...normalized.stops].sort((a, b) => a.offset - b.offset);
118
+ const colorStops = sortedStops
119
+ .map((stop) => `${stop.color} ${stop.offset}%`)
120
+ .join(", ");
121
+
122
+ if (normalized.type === "linear") {
123
+ // The engine's 0° points right; CSS's 0deg points up.
124
+ return `linear-gradient(${(normalized.angle ?? 0) + 90}deg, ${colorStops})`;
125
+ }
126
+
127
+ if (normalized.type === "angular") {
128
+ return `conic-gradient(from ${normalized.angle ?? 0}deg, ${colorStops})`;
129
+ }
130
+
131
+ return `radial-gradient(circle, ${colorStops})`;
132
+ }
package/types/color.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  import { z } from "zod";
2
2
 
3
+ export {
4
+ getColorString,
5
+ getNormalizedColor,
6
+ imagePositionCss,
7
+ isGradient,
8
+ isImagePaint,
9
+ normalizeColorConfig,
10
+ } from "./color-helpers";
11
+
3
12
  /**
4
13
  * Color type discriminator
5
14
  */
@@ -129,125 +138,3 @@ export const colorConfigSchema = z.union([
129
138
  imagePaintSchema,
130
139
  ]);
131
140
  export type ColorConfig = z.infer<typeof colorConfigSchema>;
132
-
133
- /**
134
- * Helper to normalize color config to object format
135
- */
136
- export function normalizeColorConfig(
137
- color: ColorConfig | undefined,
138
- fallback = "#000000"
139
- ): SolidColor | Gradient | ImagePaint {
140
- if (!color) {
141
- return { type: "solid", color: fallback };
142
- }
143
- if (typeof color === "string") {
144
- return { type: "solid", color };
145
- }
146
- return color;
147
- }
148
-
149
- /**
150
- * Helper to check if color is gradient
151
- */
152
- export function isGradient(color: ColorConfig | undefined): color is Gradient {
153
- if (!color || typeof color === "string") {
154
- return false;
155
- }
156
- return (
157
- color.type === "linear" ||
158
- color.type === "radial" ||
159
- color.type === "angular"
160
- );
161
- }
162
-
163
- /** True for an image fill. */
164
- export function isImagePaint(
165
- color: ColorConfig | undefined
166
- ): color is ImagePaint {
167
- return typeof color === "object" && color !== null && color.type === "image";
168
- }
169
-
170
- /**
171
- * Helper to get a solid color string from any ColorConfig
172
- * For gradients, returns the first stop color; for an image fill, its
173
- * underlay (or `fallback`)
174
- */
175
- export function getColorString(
176
- color: ColorConfig | undefined,
177
- fallback = "#000000"
178
- ): string {
179
- const normalized = normalizeColorConfig(color, fallback);
180
- if (normalized.type === "solid") {
181
- return normalized.color;
182
- }
183
- if (normalized.type === "image") {
184
- return normalized.underlay || fallback;
185
- }
186
- return normalized.stops[0]?.color || fallback;
187
- }
188
-
189
- /** CSS `background-position` for an image fill's position. */
190
- export function imagePositionCss(position: ImagePosition = "center"): string {
191
- const [first, second] = position.split("-") as [string, string | undefined];
192
- if (position === "center") {
193
- return "center";
194
- }
195
- if (second) {
196
- return `${second} ${first}`;
197
- }
198
- return first === "top" || first === "bottom"
199
- ? `center ${first}`
200
- : `${first} center`;
201
- }
202
-
203
- /**
204
- * CSS `background` for a color config, for swatches and previews: the color
205
- * itself, or a CSS gradient that matches how the engine draws it (a linear
206
- * angle of 0 runs left to right, as in the QR code).
207
- */
208
- export function getNormalizedColor(
209
- color: ColorConfig | string | undefined
210
- ): string {
211
- if (!color) {
212
- return "#000000";
213
- }
214
-
215
- if (typeof color === "string") {
216
- return color;
217
- }
218
-
219
- const normalized = normalizeColorConfig(color);
220
- if (normalized.type === "solid") {
221
- return normalized.color;
222
- }
223
-
224
- if (normalized.type === "image") {
225
- const size =
226
- normalized.fit === "tile"
227
- ? `${25 * (normalized.scale ?? 1)}% auto`
228
- : (normalized.scale ?? 1) === 1
229
- ? normalized.fit === "contain"
230
- ? "contain"
231
- : "cover"
232
- : `${100 * (normalized.scale ?? 1)}% auto`;
233
- const repeat = normalized.fit === "tile" ? "repeat" : "no-repeat";
234
- const url = `url("${normalized.src.replace(/"/g, "%22")}")`;
235
- return `${url} ${imagePositionCss(normalized.position)} / ${size} ${repeat}, ${normalized.underlay ?? "transparent"}`;
236
- }
237
-
238
- const sortedStops = [...normalized.stops].sort((a, b) => a.offset - b.offset);
239
- const colorStops = sortedStops
240
- .map((stop) => `${stop.color} ${stop.offset}%`)
241
- .join(", ");
242
-
243
- if (normalized.type === "linear") {
244
- // The engine's 0° points right; CSS's 0deg points up.
245
- return `linear-gradient(${(normalized.angle ?? 0) + 90}deg, ${colorStops})`;
246
- }
247
-
248
- if (normalized.type === "angular") {
249
- return `conic-gradient(from ${normalized.angle ?? 0}deg, ${colorStops})`;
250
- }
251
-
252
- return `radial-gradient(circle, ${colorStops})`;
253
- }
@@ -0,0 +1,222 @@
1
+ // Option lists and limits, without zod: the engine draws with these, so an
2
+ // app that only renders codes never loads zod. The zod schemas built from
3
+ // them (and their inferred types) live in the domain modules next to this
4
+ // one (art.ts, corner-dot.ts, frame.ts, qr.ts…), which re-export them.
5
+
6
+ // ── Art (art.ts) ───────────────────────────────────────────────────────────
7
+
8
+ /**
9
+ * Art modes blend a picture into the code itself (vector output, no AI):
10
+ * - "logo" (Logo QR): the logo, traced into crisp vector shapes, either fills
11
+ * the code under a fine dot screen ("blend") or sits on a rounded plate in
12
+ * the middle of a code tinted with its colors ("badge").
13
+ * - "halftone" (Image QR): the photo shows through every module around a
14
+ * small center dot that keeps the module's dark/light value, in full color
15
+ * ("color") or as an error-diffused black-and-white halftone ("mono").
16
+ * Finder, alignment and format patterns always stay crisp.
17
+ */
18
+ export const QR_ART_MODES = ["logo", "halftone"] as const;
19
+
20
+ /** Looks within each mode; the first one is the mode's default. */
21
+ export const QR_ART_VARIANTS = {
22
+ logo: ["blend", "badge"],
23
+ halftone: ["color", "mono"],
24
+ } as const satisfies Record<(typeof QR_ART_MODES)[number], readonly string[]>;
25
+
26
+ /** Largest side of an art sample grid, in pixels. */
27
+ export const QR_ART_MAX_SAMPLE_SIZE = 192;
28
+
29
+ // ── Eyes (corner-dot.ts, corner-eye.ts) ────────────────────────────────────
30
+
31
+ /**
32
+ * Eye centres to offer: every one decodes with jsQR and ZXing through a
33
+ * phone-camera model and in sharp renders (tests/catalog-*.test.ts).
34
+ */
35
+ export const CORNER_EYE_DOT_PATTERNS = [
36
+ "square",
37
+ "rounded",
38
+ "circle",
39
+ "message",
40
+ "message-reverse",
41
+ "diya",
42
+ "diya-reverse",
43
+ "rounded-triangle",
44
+ // Added after 0.0.46
45
+ "leaf",
46
+ "drop",
47
+ "plus",
48
+ "cross-rounded",
49
+ "hexagon",
50
+ "octagon",
51
+ "flower",
52
+ "heart",
53
+ "squircle",
54
+ "dots",
55
+ "extra-rounded",
56
+ "leaf-reverse",
57
+ "drop-reverse",
58
+ ] as const;
59
+
60
+ /**
61
+ * @deprecated Retired eye centres: they don't decode reliably (`diamond`
62
+ * and `star` fail ZXing at phone distances, `banner` fails jsQR in every
63
+ * sharp render). The renderer still draws them so saved designs keep
64
+ * working, but nothing offers them any more.
65
+ */
66
+ export const RETIRED_CORNER_EYE_DOT_PATTERNS = [
67
+ "diamond",
68
+ "star",
69
+ "banner",
70
+ ] as const;
71
+
72
+ /**
73
+ * Eye frames to offer: every one decodes with jsQR and ZXing through a
74
+ * phone-camera model and in sharp renders (tests/catalog-*.test.ts).
75
+ */
76
+ export const CORNER_EYE_PATTERNS = [
77
+ "square",
78
+ "rounded",
79
+ "gear",
80
+ "circle",
81
+ "diya",
82
+ "extra-rounded",
83
+ "message",
84
+ "pointy",
85
+ // Added after 0.0.46
86
+ "leaf",
87
+ "drop",
88
+ "octagon",
89
+ "bevel",
90
+ "squircle",
91
+ "cushion",
92
+ "shield",
93
+ "petal",
94
+ "leaf-reverse",
95
+ ] as const;
96
+
97
+ /**
98
+ * @deprecated Retired eye frames: `curly` fails ZXing (most Android
99
+ * scanners) at 4–6 px per module and in sharp renders. The renderer still
100
+ * draws it so saved designs keep working, but nothing offers it any more.
101
+ */
102
+ export const RETIRED_CORNER_EYE_PATTERNS = ["curly"] as const;
103
+
104
+ // ── Body (image-pattern.ts) ────────────────────────────────────────────────
105
+
106
+ export const BODY_PATTERN = [
107
+ "circle",
108
+ "circle-large",
109
+ "square",
110
+ "diamond",
111
+ "circle-mixed",
112
+ "pacman",
113
+ "rounded",
114
+ "small-square",
115
+ "vertical-line",
116
+ // Added after 0.0.46 (drawn by src/body-patterns.tsx)
117
+ "horizontal-line",
118
+ "liquid",
119
+ "liquid-horizontal",
120
+ "liquid-vertical",
121
+ "classy",
122
+ "classy-rounded",
123
+ "leaf",
124
+ "plus",
125
+ "hexagon",
126
+ "star",
127
+ "heart",
128
+ "random-dots",
129
+ "mosaic",
130
+ "octagon",
131
+ ] as const;
132
+
133
+ // ── Frames (frame.ts) ──────────────────────────────────────────────────────
134
+
135
+ export const FRAME_STYLES = [
136
+ "none",
137
+ "banner-bottom",
138
+ "banner-top",
139
+ "border",
140
+ "rounded-border",
141
+ "speech-bubble",
142
+ // Added after 0.0.46
143
+ "banner-top-bottom",
144
+ "speech-bubble-top",
145
+ "chat-bubble",
146
+ "circle",
147
+ "polaroid",
148
+ "phone",
149
+ "ticket",
150
+ "badge",
151
+ "envelope",
152
+ "tag",
153
+ "menu-card",
154
+ "sticker",
155
+ "gradient-border",
156
+ "focus",
157
+ ] as const;
158
+
159
+ /** Longest call-to-action label a frame renders. */
160
+ export const FRAME_TEXT_MAX_LENGTH = 24;
161
+
162
+ /** Label used when a frame has no `text`. Pass `""` to hide the label. */
163
+ export const DEFAULT_FRAME_TEXT = "Scan me";
164
+
165
+ /** Smallest and largest `fontScale` (label size relative to the default). */
166
+ export const FRAME_FONT_SCALE_MIN = 0.5;
167
+ export const FRAME_FONT_SCALE_MAX = 1.5;
168
+
169
+ // ── The code (qr.ts) ───────────────────────────────────────────────────────
170
+
171
+ /**
172
+ * How a logo is cropped: "square" (as uploaded), "rounded" corners or a
173
+ * "circle". A plate behind the logo takes the same shape.
174
+ */
175
+ export const LOGO_SHAPES = ["square", "rounded", "circle"] as const;
176
+
177
+ /**
178
+ * Smallest and largest logo width, as a share of the code's width. Above
179
+ * 25% even level H stops reading in our decode tests (tests/engine-options).
180
+ */
181
+ export const LOGO_SIZE_MIN = 0.1;
182
+ export const LOGO_SIZE_MAX = 0.3;
183
+ /** Logo width `getQRData` uses when no size is given (25%). */
184
+ export const LOGO_SIZE_DEFAULT = 0.25;
185
+ /** Most clear space around a logo, in modules. */
186
+ export const LOGO_PADDING_MAX = 2;
187
+
188
+ /** Smallest and largest `moduleScale` (size of each data module). */
189
+ export const MODULE_SCALE_MIN = 0.5;
190
+ export const MODULE_SCALE_MAX = 1;
191
+
192
+ /**
193
+ * Share of the code a logo may cover before `autoLevel` raises error
194
+ * correction to H (level L recovers about 7%).
195
+ */
196
+ export const AUTO_LEVEL_LOGO_COVERAGE = 0.07;
197
+
198
+ /**
199
+ * Outline of the whole code: "square" (the QR symbol as is), "circle" or
200
+ * "heart": the symbol sits in a disc or a heart filled with decorative
201
+ * modules. Decoders read only the symbol, which keeps its quiet ring
202
+ * (`margin`, at least QR_CIRCLE_QUIET_MIN modules) before the decoration
203
+ * starts. `shape` also takes a `QRSilhouette`, an outline of your own.
204
+ */
205
+ export const QR_SHAPES = ["square", "circle", "heart"] as const;
206
+ /** Smallest light ring between a shaped code's symbol and its decoration. */
207
+ export const QR_CIRCLE_QUIET_MIN = 3;
208
+
209
+ /** Most cells along a silhouette's longer side. */
210
+ export const QR_SILHOUETTE_MAX_CELLS = 64;
211
+ /** Fewest cells along each side of a silhouette. */
212
+ export const QR_SILHOUETTE_MIN_CELLS = 8;
213
+ /**
214
+ * Smallest share of the artwork's width the symbol and its quiet ring may
215
+ * take inside a silhouette (a circle code's is about 0.7, a heart's 0.6).
216
+ * Thinner silhouettes are refused: the code would be a small square in a
217
+ * large field of decoration.
218
+ */
219
+ export const QR_SILHOUETTE_MIN_SHARE = 0.42;
220
+
221
+ /** The three finder patterns, for per-eye colors. */
222
+ export const EYE_POSITIONS = ["topLeft", "topRight", "bottomLeft"] as const;