qrdx 0.0.45 → 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.
Files changed (206) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +353 -300
  3. package/dist/index.js +27 -7
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +27 -7
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/qr-code-canvas.js +12 -0
  8. package/dist/qr-code-canvas.js.map +1 -0
  9. package/dist/qr-code-canvas.mjs +12 -0
  10. package/dist/qr-code-canvas.mjs.map +1 -0
  11. package/dist/src/api.d.ts.map +1 -1
  12. package/dist/src/art-trace.d.ts +46 -0
  13. package/dist/src/art-trace.d.ts.map +1 -0
  14. package/dist/src/art.d.ts +138 -0
  15. package/dist/src/art.d.ts.map +1 -0
  16. package/dist/src/body-patterns.d.ts +34 -0
  17. package/dist/src/body-patterns.d.ts.map +1 -0
  18. package/dist/src/codegen.d.ts +5 -5
  19. package/dist/src/codegen.d.ts.map +1 -1
  20. package/dist/src/codeword-map.d.ts +40 -0
  21. package/dist/src/codeword-map.d.ts.map +1 -0
  22. package/dist/src/constants.d.ts +4 -7
  23. package/dist/src/constants.d.ts.map +1 -1
  24. package/dist/src/corner-dot.d.ts +3 -1
  25. package/dist/src/corner-dot.d.ts.map +1 -1
  26. package/dist/src/corner-eye.d.ts +5 -2
  27. package/dist/src/corner-eye.d.ts.map +1 -1
  28. package/dist/src/detection.d.ts.map +1 -1
  29. package/dist/src/download.d.ts +22 -5
  30. package/dist/src/download.d.ts.map +1 -1
  31. package/dist/src/eps.d.ts +62 -0
  32. package/dist/src/eps.d.ts.map +1 -0
  33. package/dist/src/frame-icons.d.ts +11 -0
  34. package/dist/src/frame-icons.d.ts.map +1 -0
  35. package/dist/src/frame-import.d.ts +61 -0
  36. package/dist/src/frame-import.d.ts.map +1 -0
  37. package/dist/src/frame-spec.d.ts +24 -0
  38. package/dist/src/frame-spec.d.ts.map +1 -0
  39. package/dist/src/frame-styles.d.ts +50 -0
  40. package/dist/src/frame-styles.d.ts.map +1 -0
  41. package/dist/src/frame.d.ts +126 -0
  42. package/dist/src/frame.d.ts.map +1 -0
  43. package/dist/src/frames/builtin.d.ts +8 -0
  44. package/dist/src/frames/builtin.d.ts.map +1 -0
  45. package/dist/src/frames/official.d.ts +18 -0
  46. package/dist/src/frames/official.d.ts.map +1 -0
  47. package/dist/src/helpers.d.ts +15 -2
  48. package/dist/src/helpers.d.ts.map +1 -1
  49. package/dist/src/index.d.ts +24 -13
  50. package/dist/src/index.d.ts.map +1 -1
  51. package/dist/src/logo-budget.d.ts +54 -0
  52. package/dist/src/logo-budget.d.ts.map +1 -0
  53. package/dist/src/logo-cleanup.d.ts +25 -0
  54. package/dist/src/logo-cleanup.d.ts.map +1 -0
  55. package/dist/src/logo.d.ts +28 -0
  56. package/dist/src/logo.d.ts.map +1 -0
  57. package/dist/src/print.d.ts +73 -0
  58. package/dist/src/print.d.ts.map +1 -0
  59. package/dist/src/qr-code-canvas.d.ts +13 -0
  60. package/dist/src/qr-code-canvas.d.ts.map +1 -0
  61. package/dist/src/qr-code.d.ts +4 -2
  62. package/dist/src/qr-code.d.ts.map +1 -1
  63. package/dist/src/qr-outline.d.ts +41 -0
  64. package/dist/src/qr-outline.d.ts.map +1 -0
  65. package/dist/src/qr-shape.d.ts +72 -0
  66. package/dist/src/qr-shape.d.ts.map +1 -0
  67. package/dist/src/scan-risk.d.ts +40 -0
  68. package/dist/src/scan-risk.d.ts.map +1 -0
  69. package/dist/src/scan-score.d.ts +154 -0
  70. package/dist/src/scan-score.d.ts.map +1 -0
  71. package/dist/src/shapes.d.ts +36 -0
  72. package/dist/src/shapes.d.ts.map +1 -0
  73. package/dist/src/silhouette.d.ts +28 -0
  74. package/dist/src/silhouette.d.ts.map +1 -0
  75. package/dist/src/utils/color.d.ts.map +1 -1
  76. package/dist/src/utils/fmt.d.ts +24 -0
  77. package/dist/src/utils/fmt.d.ts.map +1 -0
  78. package/dist/src/utils/paint.d.ts +80 -0
  79. package/dist/src/utils/paint.d.ts.map +1 -0
  80. package/dist/src/utils/parse-color.d.ts +21 -0
  81. package/dist/src/utils/parse-color.d.ts.map +1 -0
  82. package/dist/src/utils/path-data.d.ts +24 -0
  83. package/dist/src/utils/path-data.d.ts.map +1 -0
  84. package/dist/src/utils/png.d.ts +16 -0
  85. package/dist/src/utils/png.d.ts.map +1 -0
  86. package/dist/src/utils/polygon-clip.d.ts +26 -0
  87. package/dist/src/utils/polygon-clip.d.ts.map +1 -0
  88. package/dist/src/utils/print-shared.d.ts +20 -0
  89. package/dist/src/utils/print-shared.d.ts.map +1 -0
  90. package/dist/src/utils/svg-geometry.d.ts +49 -0
  91. package/dist/src/utils/svg-geometry.d.ts.map +1 -0
  92. package/dist/src/utils/svg-gradient.d.ts +59 -0
  93. package/dist/src/utils/svg-gradient.d.ts.map +1 -0
  94. package/dist/src/utils/svg-painter.d.ts +152 -0
  95. package/dist/src/utils/svg-painter.d.ts.map +1 -0
  96. package/dist/src/utils.d.ts +18 -2
  97. package/dist/src/utils.d.ts.map +1 -1
  98. package/dist/types/art.d.ts +64 -0
  99. package/dist/types/art.d.ts.map +1 -0
  100. package/dist/types/color.d.ts +125 -7
  101. package/dist/types/color.d.ts.map +1 -1
  102. package/dist/types/corner-dot.d.ts +52 -2
  103. package/dist/types/corner-dot.d.ts.map +1 -1
  104. package/dist/types/corner-eye.d.ts +43 -2
  105. package/dist/types/corner-eye.d.ts.map +1 -1
  106. package/dist/types/frame-spec.d.ts +3509 -0
  107. package/dist/types/frame-spec.d.ts.map +1 -0
  108. package/dist/types/frame.d.ts +68 -0
  109. package/dist/types/frame.d.ts.map +1 -0
  110. package/dist/types/image-pattern.d.ts +15 -1
  111. package/dist/types/image-pattern.d.ts.map +1 -1
  112. package/dist/types/index.d.ts +15 -9
  113. package/dist/types/index.d.ts.map +1 -1
  114. package/dist/types/index.js +6 -0
  115. package/dist/types/index.js.map +1 -0
  116. package/dist/types/index.mjs +6 -0
  117. package/dist/types/index.mjs.map +1 -0
  118. package/dist/types/qr.d.ts +1684 -4
  119. package/dist/types/qr.d.ts.map +1 -1
  120. package/dist/types/template.d.ts +2 -2
  121. package/dist/types/template.d.ts.map +1 -1
  122. package/package.json +63 -20
  123. package/src/api.tsx +67 -17
  124. package/src/art-trace.ts +554 -0
  125. package/src/art.tsx +2226 -0
  126. package/src/body-patterns.tsx +389 -0
  127. package/src/codegen.ts +10 -5
  128. package/src/codeword-map.ts +265 -0
  129. package/src/constants.ts +4 -8
  130. package/src/corner-dot.tsx +209 -33
  131. package/src/corner-eye.ts +328 -60
  132. package/src/detection.ts +5 -11
  133. package/src/download.tsx +123 -52
  134. package/src/eps.ts +701 -0
  135. package/src/frame-icons.ts +325 -0
  136. package/src/frame-import.ts +1198 -0
  137. package/src/frame-spec.ts +518 -0
  138. package/src/frame-styles.ts +1095 -0
  139. package/src/frame.tsx +630 -0
  140. package/src/frames/builtin/banner-bottom.json +58 -0
  141. package/src/frames/builtin/circle.json +81 -0
  142. package/src/frames/builtin/rounded-border.json +60 -0
  143. package/src/frames/builtin/ticket.json +51 -0
  144. package/src/frames/builtin.ts +20 -0
  145. package/src/frames/official/attendance.json +110 -0
  146. package/src/frames/official/audio-guide.json +95 -0
  147. package/src/frames/official/book-now.json +103 -0
  148. package/src/frames/official/check-in.json +110 -0
  149. package/src/frames/official/christmas.json +131 -0
  150. package/src/frames/official/donate.json +77 -0
  151. package/src/frames/official/event-ticket.json +77 -0
  152. package/src/frames/official/feedback-bubble.json +73 -0
  153. package/src/frames/official/follow-us.json +83 -0
  154. package/src/frames/official/get-the-app.json +107 -0
  155. package/src/frames/official/halloween.json +80 -0
  156. package/src/frames/official/new-year.json +94 -0
  157. package/src/frames/official/order-at-table.json +86 -0
  158. package/src/frames/official/product-info.json +119 -0
  159. package/src/frames/official/register-product.json +77 -0
  160. package/src/frames/official/review-us.json +127 -0
  161. package/src/frames/official/rsvp-card.json +112 -0
  162. package/src/frames/official/save-contact.json +117 -0
  163. package/src/frames/official/scan-to-pay.json +94 -0
  164. package/src/frames/official/shop-window.json +81 -0
  165. package/src/frames/official/sign-rider.json +81 -0
  166. package/src/frames/official/table-tent.json +75 -0
  167. package/src/frames/official/wifi-card.json +89 -0
  168. package/src/frames/official/winter.json +142 -0
  169. package/src/frames/official.ts +77 -0
  170. package/src/helpers.ts +168 -11
  171. package/src/index.tsx +141 -172
  172. package/src/logo-budget.ts +226 -0
  173. package/src/logo-cleanup.ts +146 -0
  174. package/src/logo.tsx +137 -0
  175. package/src/print.ts +794 -0
  176. package/src/qr-code-canvas.tsx +241 -0
  177. package/src/qr-code.tsx +51 -16
  178. package/src/qr-outline.ts +511 -0
  179. package/src/qr-shape.ts +255 -0
  180. package/src/scan-risk.ts +197 -0
  181. package/src/scan-score.ts +1629 -0
  182. package/src/shapes.ts +169 -0
  183. package/src/silhouette.ts +334 -0
  184. package/src/utils/color.ts +10 -1
  185. package/src/utils/fmt.ts +59 -0
  186. package/src/utils/paint.ts +317 -0
  187. package/src/utils/parse-color.ts +135 -0
  188. package/src/utils/path-data.ts +182 -0
  189. package/src/utils/png.ts +175 -0
  190. package/src/utils/polygon-clip.ts +163 -0
  191. package/src/utils/print-shared.ts +74 -0
  192. package/src/utils/svg-geometry.ts +838 -0
  193. package/src/utils/svg-gradient.ts +407 -0
  194. package/src/utils/svg-painter.ts +946 -0
  195. package/src/utils.tsx +794 -385
  196. package/types/art.ts +74 -0
  197. package/types/color.ts +132 -12
  198. package/types/corner-dot.ts +41 -4
  199. package/types/corner-eye.ts +31 -4
  200. package/types/frame-spec.ts +748 -0
  201. package/types/frame.ts +67 -0
  202. package/types/image-pattern.ts +15 -0
  203. package/types/index.ts +106 -4
  204. package/types/qr.ts +180 -2
  205. package/types/template.ts +2 -2
  206. package/dist/cli.js +0 -4231
package/types/art.ts ADDED
@@ -0,0 +1,74 @@
1
+ import { z } from "zod";
2
+
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;
14
+
15
+ export const qrArtModeSchema = z.enum(QR_ART_MODES);
16
+ export type QRArtMode = z.infer<typeof qrArtModeSchema>;
17
+
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
+ export const qrArtVariantSchema = z.enum([
25
+ ...QR_ART_VARIANTS.logo,
26
+ ...QR_ART_VARIANTS.halftone,
27
+ ]);
28
+ export type QRArtVariant = z.infer<typeof qrArtVariantSchema>;
29
+
30
+ /** Largest side of an art sample grid, in pixels. */
31
+ export const QR_ART_MAX_SAMPLE_SIZE = 192;
32
+
33
+ const base64Length = (bytes: number) => Math.ceil(bytes / 3) * 4;
34
+
35
+ /**
36
+ * A small RGBA bitmap sampled from the source image (see `createQRArtImage`
37
+ * and `loadQRArtImage`). Storing pixels instead of an image URL keeps
38
+ * rendering synchronous and identical in the browser, on the server and in
39
+ * the CLI, and never fetches anything.
40
+ */
41
+ export const qrArtImageSchema = z
42
+ .object({
43
+ width: z.number().int().min(1).max(QR_ART_MAX_SAMPLE_SIZE),
44
+ height: z.number().int().min(1).max(QR_ART_MAX_SAMPLE_SIZE),
45
+ /** Base64 of the RGBA bytes, row by row (width × height × 4 bytes) */
46
+ data: z
47
+ .string()
48
+ .max(base64Length(QR_ART_MAX_SAMPLE_SIZE * QR_ART_MAX_SAMPLE_SIZE * 4)),
49
+ })
50
+ .refine(
51
+ (image) =>
52
+ image.data.length === base64Length(image.width * image.height * 4),
53
+ { message: "Art image data does not match its width and height" }
54
+ );
55
+ export type QRArtImage = z.infer<typeof qrArtImageSchema>;
56
+
57
+ export const qrArtSchema = z.object({
58
+ mode: qrArtModeSchema,
59
+ image: qrArtImageSchema,
60
+ /** 0 = plain code, 1 = strongest effect (default 0.6) */
61
+ intensity: z.number().min(0).max(1).optional(),
62
+ /**
63
+ * Look within the mode (see QR_ART_VARIANTS). Omitted, or a variant of the
64
+ * other mode, means the mode's default: "blend" for logo, "color" for
65
+ * halftone.
66
+ */
67
+ variant: qrArtVariantSchema.optional(),
68
+ /**
69
+ * Logo mode: color the finder eyes from the logo (default true). Per-eye
70
+ * `eyeColors` still win.
71
+ */
72
+ matchEyes: z.boolean().optional(),
73
+ });
74
+ export type QRArt = z.infer<typeof qrArtSchema>;
package/types/color.ts CHANGED
@@ -3,11 +3,19 @@ import { z } from "zod";
3
3
  /**
4
4
  * Color type discriminator
5
5
  */
6
- export const colorTypeSchema = z.enum(["solid", "linear", "radial"]);
6
+ export const colorTypeSchema = z.enum([
7
+ "solid",
8
+ "linear",
9
+ "radial",
10
+ "angular",
11
+ "image",
12
+ ]);
7
13
  export type ColorType = z.infer<typeof colorTypeSchema>;
8
14
 
9
15
  /**
10
- * Solid color configuration
16
+ * Solid color configuration. `color` is any CSS color the engine parses
17
+ * (hex with or without alpha, rgb()/rgba(), a name); alpha is kept in it,
18
+ * e.g. "#1d4ed880" or "rgba(29, 78, 216, 0.5)".
11
19
  */
12
20
  export const solidColorSchema = z.object({
13
21
  type: z.literal("solid"),
@@ -16,7 +24,8 @@ export const solidColorSchema = z.object({
16
24
  export type SolidColor = z.infer<typeof solidColorSchema>;
17
25
 
18
26
  /**
19
- * Gradient stop configuration
27
+ * Gradient stop configuration. A stop's color may carry alpha, as a solid
28
+ * color does.
20
29
  */
21
30
  export const gradientStopSchema = z.object({
22
31
  color: z.string(),
@@ -45,19 +54,79 @@ export const radialGradientSchema = z.object({
45
54
  });
46
55
  export type RadialGradient = z.infer<typeof radialGradientSchema>;
47
56
 
57
+ /**
58
+ * Angular (conic) gradient: the color sweeps clockwise around the centre of
59
+ * the shape it fills, like CSS `conic-gradient(from <angle>deg, …)`.
60
+ * `angle` is where the sweep starts, in degrees clockwise from the top
61
+ * (0 = 12 o'clock). Offsets run 0–100 around the full turn.
62
+ */
63
+ export const angularGradientSchema = z.object({
64
+ type: z.literal("angular"),
65
+ stops: z.array(gradientStopSchema).min(2),
66
+ angle: z.number().optional().default(0),
67
+ });
68
+ export type AngularGradient = z.infer<typeof angularGradientSchema>;
69
+
70
+ /** Any gradient: linear, radial or angular. */
71
+ export type Gradient = LinearGradient | RadialGradient | AngularGradient;
72
+
73
+ /** How an image fill sits in the code: fill it, fit inside it, or repeat. */
74
+ export const imageFitSchema = z.enum(["cover", "contain", "tile"]);
75
+ export type ImageFit = z.infer<typeof imageFitSchema>;
76
+
77
+ /** Which part of the image stays in view (cover) or where it sits (contain). */
78
+ export const imagePositionSchema = z.enum([
79
+ "top-left",
80
+ "top",
81
+ "top-right",
82
+ "left",
83
+ "center",
84
+ "right",
85
+ "bottom-left",
86
+ "bottom",
87
+ "bottom-right",
88
+ ]);
89
+ export type ImagePosition = z.infer<typeof imagePositionSchema>;
90
+
91
+ /**
92
+ * An image fill: a picture painted through the shapes it fills, laid over
93
+ * the code's whole area (so the dots and the eyes show one picture).
94
+ *
95
+ * `src` is held like a logo: a data URL (PNG or JPEG embed everywhere; other
96
+ * formats are redrawn as PNG in the browser). Servers never fetch a remote
97
+ * address. `scale` zooms around `position` (cover, contain) or sizes the
98
+ * tiles (1 = four across). `opacity` lets `underlay`, a solid color under
99
+ * the picture, show through: darken a photo for the dots, lighten it for
100
+ * the background.
101
+ */
102
+ export const imagePaintSchema = z.object({
103
+ type: z.literal("image"),
104
+ src: z.string().min(1),
105
+ fit: imageFitSchema.optional().default("cover"),
106
+ scale: z.number().min(0.1).max(4).optional().default(1),
107
+ position: imagePositionSchema.optional().default("center"),
108
+ opacity: z.number().min(0).max(1).optional().default(1),
109
+ underlay: z.string().optional(),
110
+ });
111
+ export type ImagePaint = z.infer<typeof imagePaintSchema>;
112
+
48
113
  /**
49
114
  * Union type for color configuration
50
115
  * Supports:
51
116
  * - string: backward compatible solid color
52
117
  * - SolidColor: explicit solid color object
53
- * - LinearGradient: linear gradient with start/end colors and angle
54
- * - RadialGradient: radial gradient with start/end colors and positioning
118
+ * - LinearGradient: linear gradient with stops and an angle
119
+ * - RadialGradient: radial gradient from the centre out
120
+ * - AngularGradient: conic gradient around the centre
121
+ * - ImagePaint: a picture painted through the shapes
55
122
  */
56
123
  export const colorConfigSchema = z.union([
57
124
  z.string(),
58
125
  solidColorSchema,
59
126
  linearGradientSchema,
60
127
  radialGradientSchema,
128
+ angularGradientSchema,
129
+ imagePaintSchema,
61
130
  ]);
62
131
  export type ColorConfig = z.infer<typeof colorConfigSchema>;
63
132
 
@@ -67,7 +136,7 @@ export type ColorConfig = z.infer<typeof colorConfigSchema>;
67
136
  export function normalizeColorConfig(
68
137
  color: ColorConfig | undefined,
69
138
  fallback = "#000000"
70
- ): SolidColor | LinearGradient | RadialGradient {
139
+ ): SolidColor | Gradient | ImagePaint {
71
140
  if (!color) {
72
141
  return { type: "solid", color: fallback };
73
142
  }
@@ -80,18 +149,28 @@ export function normalizeColorConfig(
80
149
  /**
81
150
  * Helper to check if color is gradient
82
151
  */
83
- export function isGradient(
84
- color: ColorConfig | undefined
85
- ): color is LinearGradient | RadialGradient {
152
+ export function isGradient(color: ColorConfig | undefined): color is Gradient {
86
153
  if (!color || typeof color === "string") {
87
154
  return false;
88
155
  }
89
- return color.type === "linear" || color.type === "radial";
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";
90
168
  }
91
169
 
92
170
  /**
93
171
  * Helper to get a solid color string from any ColorConfig
94
- * For gradients, returns the first stop color
172
+ * For gradients, returns the first stop color; for an image fill, its
173
+ * underlay (or `fallback`)
95
174
  */
96
175
  export function getColorString(
97
176
  color: ColorConfig | undefined,
@@ -101,9 +180,31 @@ export function getColorString(
101
180
  if (normalized.type === "solid") {
102
181
  return normalized.color;
103
182
  }
183
+ if (normalized.type === "image") {
184
+ return normalized.underlay || fallback;
185
+ }
104
186
  return normalized.stops[0]?.color || fallback;
105
187
  }
106
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
+ */
107
208
  export function getNormalizedColor(
108
209
  color: ColorConfig | string | undefined
109
210
  ): string {
@@ -120,13 +221,32 @@ export function getNormalizedColor(
120
221
  return normalized.color;
121
222
  }
122
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
+
123
238
  const sortedStops = [...normalized.stops].sort((a, b) => a.offset - b.offset);
124
239
  const colorStops = sortedStops
125
240
  .map((stop) => `${stop.color} ${stop.offset}%`)
126
241
  .join(", ");
127
242
 
128
243
  if (normalized.type === "linear") {
129
- return `linear-gradient(${normalized.angle ?? 0}deg, ${colorStops})`;
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})`;
130
250
  }
131
251
 
132
252
  return `radial-gradient(circle, ${colorStops})`;
@@ -1,21 +1,58 @@
1
1
  import { z } from "zod";
2
2
 
3
+ /**
4
+ * Eye centres to offer: every one decodes with jsQR and ZXing through a
5
+ * phone-camera model and in sharp renders (tests/catalog-*.test.ts).
6
+ */
3
7
  export const CORNER_EYE_DOT_PATTERNS = [
4
8
  "square",
5
9
  "rounded",
6
10
  "circle",
7
- "diamond",
8
11
  "message",
9
12
  "message-reverse",
10
13
  "diya",
11
14
  "diya-reverse",
12
15
  "rounded-triangle",
16
+ // Added after 0.0.46
17
+ "leaf",
18
+ "drop",
19
+ "plus",
20
+ "cross-rounded",
21
+ "hexagon",
22
+ "octagon",
23
+ "flower",
24
+ "heart",
25
+ "squircle",
26
+ "dots",
27
+ "extra-rounded",
28
+ "leaf-reverse",
29
+ "drop-reverse",
30
+ ] as const;
31
+
32
+ /**
33
+ * @deprecated Retired eye centres: they don't decode reliably (`diamond`
34
+ * and `star` fail ZXing at phone distances, `banner` fails jsQR in every
35
+ * sharp render). The renderer still draws them so saved designs keep
36
+ * working, but nothing offers them any more.
37
+ */
38
+ export const RETIRED_CORNER_EYE_DOT_PATTERNS = [
39
+ "diamond",
13
40
  "star",
14
41
  "banner",
15
42
  ] as const;
16
43
 
17
- // Zod schema
18
- export const cornerEyeDotPatternSchema = z.enum(CORNER_EYE_DOT_PATTERNS);
44
+ /** Accepts current and retired values, so saved designs still validate. */
45
+ export const cornerEyeDotPatternSchema = z.enum([
46
+ ...CORNER_EYE_DOT_PATTERNS,
47
+ ...RETIRED_CORNER_EYE_DOT_PATTERNS,
48
+ ]);
49
+
50
+ /** Current values only: for anything that offers a choice (UI, AI, MCP). */
51
+ export const pickableCornerEyeDotPatternSchema = z.enum(
52
+ CORNER_EYE_DOT_PATTERNS
53
+ );
19
54
 
20
- // Inferred type
55
+ // Inferred types
21
56
  export type CornerEyeDotPattern = z.infer<typeof cornerEyeDotPatternSchema>;
57
+ export type PickableCornerEyeDotPattern =
58
+ (typeof CORNER_EYE_DOT_PATTERNS)[number];
@@ -1,5 +1,9 @@
1
1
  import { z } from "zod";
2
2
 
3
+ /**
4
+ * Eye frames to offer: every one decodes with jsQR and ZXing through a
5
+ * phone-camera model and in sharp renders (tests/catalog-*.test.ts).
6
+ */
3
7
  export const CORNER_EYE_PATTERNS = [
4
8
  "square",
5
9
  "rounded",
@@ -9,11 +13,34 @@ export const CORNER_EYE_PATTERNS = [
9
13
  "extra-rounded",
10
14
  "message",
11
15
  "pointy",
12
- "curly",
16
+ // Added after 0.0.46
17
+ "leaf",
18
+ "drop",
19
+ "octagon",
20
+ "bevel",
21
+ "squircle",
22
+ "cushion",
23
+ "shield",
24
+ "petal",
25
+ "leaf-reverse",
13
26
  ] as const;
14
27
 
15
- // Zod schema
16
- export const cornerEyePatternSchema = z.enum(CORNER_EYE_PATTERNS);
28
+ /**
29
+ * @deprecated Retired eye frames: `curly` fails ZXing (most Android
30
+ * scanners) at 4–6 px per module and in sharp renders. The renderer still
31
+ * draws it so saved designs keep working, but nothing offers it any more.
32
+ */
33
+ export const RETIRED_CORNER_EYE_PATTERNS = ["curly"] as const;
17
34
 
18
- // Inferred type
35
+ /** Accepts current and retired values, so saved designs still validate. */
36
+ export const cornerEyePatternSchema = z.enum([
37
+ ...CORNER_EYE_PATTERNS,
38
+ ...RETIRED_CORNER_EYE_PATTERNS,
39
+ ]);
40
+
41
+ /** Current values only: for anything that offers a choice (UI, AI, MCP). */
42
+ export const pickableCornerEyePatternSchema = z.enum(CORNER_EYE_PATTERNS);
43
+
44
+ // Inferred types
19
45
  export type CornerEyePattern = z.infer<typeof cornerEyePatternSchema>;
46
+ export type PickableCornerEyePattern = (typeof CORNER_EYE_PATTERNS)[number];