qrdx 0.0.57 → 0.0.58
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/README.md +22 -6
- package/dist/angular.js +33 -3
- package/dist/angular.js.map +1 -1
- package/dist/angular.mjs +33 -3
- package/dist/angular.mjs.map +1 -1
- package/dist/core.js +7 -7
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +7 -7
- package/dist/core.mjs.map +1 -1
- package/dist/element.browser.mjs +6 -6
- package/dist/element.browser.mjs.map +1 -1
- package/dist/element.js +1 -1
- package/dist/element.js.map +1 -1
- package/dist/element.mjs +1 -1
- package/dist/element.mjs.map +1 -1
- package/dist/frames-index.js +1 -1
- package/dist/frames-index.js.map +1 -1
- package/dist/frames-index.mjs +1 -1
- package/dist/frames-index.mjs.map +1 -1
- package/dist/frames-official.js +1 -1
- package/dist/frames-official.js.map +1 -1
- package/dist/frames-official.mjs +1 -1
- package/dist/frames-official.mjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/dist/qr-code-canvas.js +1 -1
- package/dist/qr-code-canvas.js.map +1 -1
- package/dist/qr-code-canvas.mjs +1 -1
- package/dist/qr-code-canvas.mjs.map +1 -1
- package/dist/schemas.js +1 -1
- package/dist/schemas.js.map +1 -1
- package/dist/schemas.mjs +1 -1
- package/dist/schemas.mjs.map +1 -1
- package/dist/src/angular.d.ts +9 -3
- package/dist/src/download.d.ts +32 -6
- package/dist/src/download.d.ts.map +1 -1
- package/dist/src/element.d.ts +10 -1
- package/dist/src/element.d.ts.map +1 -1
- package/dist/src/engine.d.ts +5 -2
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/eps.d.ts.map +1 -1
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/frame.d.ts +24 -0
- package/dist/src/frame.d.ts.map +1 -1
- package/dist/src/frames/catalogue/all.d.ts.map +1 -1
- package/dist/src/frames/catalogue/batches.d.ts +6 -0
- package/dist/src/frames/catalogue/batches.d.ts.map +1 -0
- package/dist/src/frames/catalogue/call-to-action.d.ts.map +1 -1
- package/dist/src/frames/catalogue/counts.d.ts +4 -2
- package/dist/src/frames/catalogue/counts.d.ts.map +1 -1
- package/dist/src/frames/catalogue/index.d.ts.map +1 -1
- package/dist/src/frames/catalogue/objects.d.ts +5 -0
- package/dist/src/frames/catalogue/objects.d.ts.map +1 -0
- package/dist/src/frames/catalogue/playful.d.ts +5 -0
- package/dist/src/frames/catalogue/playful.d.ts.map +1 -0
- package/dist/src/frames/catalogue/tags.d.ts.map +1 -1
- package/dist/src/frames/collections.d.ts.map +1 -1
- package/dist/src/frames/official-types.d.ts +1 -1
- package/dist/src/frames/official-types.d.ts.map +1 -1
- package/dist/src/frames/official.d.ts.map +1 -1
- package/dist/src/gif.d.ts +40 -0
- package/dist/src/gif.d.ts.map +1 -0
- package/dist/src/helpers.d.ts +1 -1
- package/dist/src/helpers.d.ts.map +1 -1
- package/dist/src/ico.d.ts +11 -0
- package/dist/src/ico.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/looks.d.ts +101 -0
- package/dist/src/looks.d.ts.map +1 -0
- package/dist/src/plain.d.ts.map +1 -1
- package/dist/src/print.d.ts.map +1 -1
- package/dist/src/qr-code-canvas.d.ts.map +1 -1
- package/dist/src/qr-code-props.d.ts.map +1 -1
- package/dist/src/qr-frame-svg.d.ts +10 -0
- package/dist/src/qr-frame-svg.d.ts.map +1 -0
- package/dist/src/scan-score.d.ts.map +1 -1
- package/dist/src/utils/gif.d.ts +61 -0
- package/dist/src/utils/gif.d.ts.map +1 -0
- package/dist/src/utils/ico.d.ts +30 -0
- package/dist/src/utils/ico.d.ts.map +1 -0
- package/dist/src/utils/parse-color.d.ts +1 -1
- package/dist/src/utils/parse-color.d.ts.map +1 -1
- package/dist/src/utils/print-shared.d.ts.map +1 -1
- package/dist/src/utils/svg-painter.d.ts +13 -0
- package/dist/src/utils/svg-painter.d.ts.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/vanilla-api.d.ts +2 -2
- package/dist/src/vanilla-api.d.ts.map +1 -1
- package/dist/src/vue.d.ts +1 -1
- package/dist/src/vue.d.ts.map +1 -1
- package/dist/types/constants.d.ts +41 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/index.js +2 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +2 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/plain.d.ts +2 -2
- package/dist/types/plain.d.ts.map +1 -1
- package/dist/types/qr.d.ts +399 -1
- package/dist/types/qr.d.ts.map +1 -1
- package/dist/types/react.d.ts +10 -1
- package/dist/types/react.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +1 -1
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/vanilla.browser.mjs +34 -34
- package/dist/vanilla.browser.mjs.map +1 -1
- package/dist/vue.js +1 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +1 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +6 -2
- package/src/angular.ts +14 -2
- package/src/download.tsx +92 -7
- package/src/element.ts +16 -1
- package/src/engine.ts +22 -0
- package/src/eps.ts +8 -1
- package/src/export.ts +16 -0
- package/src/frame.tsx +51 -0
- package/src/frames/catalogue/all.ts +202 -0
- package/src/frames/catalogue/batches.ts +114 -0
- package/src/frames/catalogue/call-to-action.ts +58 -0
- package/src/frames/catalogue/counts.ts +4 -2
- package/src/frames/catalogue/index.ts +808 -0
- package/src/frames/catalogue/objects.ts +65 -0
- package/src/frames/catalogue/playful.ts +97 -0
- package/src/frames/catalogue/tags.ts +137 -0
- package/src/frames/collections.ts +2 -0
- package/src/frames/official/badge-bottom-light.json +91 -0
- package/src/frames/official/badge-bottom.json +79 -0
- package/src/frames/official/billboard-campaign.json +274 -0
- package/src/frames/official/billboard-light.json +287 -0
- package/src/frames/official/bookmark-light.json +88 -0
- package/src/frames/official/bookmark-strip.json +83 -0
- package/src/frames/official/border-medium.json +71 -0
- package/src/frames/official/border-thick.json +71 -0
- package/src/frames/official/border-thin.json +71 -0
- package/src/frames/official/bottle-label.json +136 -0
- package/src/frames/official/bottle-light.json +133 -0
- package/src/frames/official/camera-viewfinder.json +174 -0
- package/src/frames/official/cassette-tape.json +236 -0
- package/src/frames/official/cat-with-card-light.json +246 -0
- package/src/frames/official/cat-with-card.json +234 -0
- package/src/frames/official/cinema-marquee.json +537 -0
- package/src/frames/official/circle-viewfinder.json +87 -0
- package/src/frames/official/clapperboard-light.json +163 -0
- package/src/frames/official/clapperboard-scene.json +151 -0
- package/src/frames/official/comic-panel.json +386 -0
- package/src/frames/official/corner-tab-light.json +101 -0
- package/src/frames/official/corner-tab.json +89 -0
- package/src/frames/official/crystal-ball.json +105 -0
- package/src/frames/official/delivery-box-light.json +132 -0
- package/src/frames/official/delivery-box-track.json +132 -0
- package/src/frames/official/fish-tank.json +276 -0
- package/src/frames/official/flag-light.json +136 -0
- package/src/frames/official/flag-team.json +127 -0
- package/src/frames/official/floppy-disk.json +106 -0
- package/src/frames/official/flying-saucer.json +128 -0
- package/src/frames/official/gallery-frame.json +195 -0
- package/src/frames/official/globe-stand.json +136 -0
- package/src/frames/official/gumball-machine.json +451 -0
- package/src/frames/official/heart-light.json +59 -0
- package/src/frames/official/heart-scan.json +51 -0
- package/src/frames/official/hexagon-light.json +87 -0
- package/src/frames/official/hexagon-scan.json +72 -0
- package/src/frames/official/hot-air-balloon.json +132 -0
- package/src/frames/official/jigsaw-piece-light.json +68 -0
- package/src/frames/official/jigsaw-piece.json +60 -0
- package/src/frames/official/laptop-screen.json +137 -0
- package/src/frames/official/lighthouse-tower.json +132 -0
- package/src/frames/official/magnifying-glass.json +85 -0
- package/src/frames/official/mailbox-flag.json +112 -0
- package/src/frames/official/mailbox-light.json +120 -0
- package/src/frames/official/map-pin-light.json +76 -0
- package/src/frames/official/map-pin.json +58 -0
- package/src/frames/official/matchbox-drawer.json +170 -0
- package/src/frames/official/microwave-door.json +220 -0
- package/src/frames/official/milk-carton.json +129 -0
- package/src/frames/official/monitor-screen.json +111 -0
- package/src/frames/official/monster-mouth.json +180 -0
- package/src/frames/official/mug-light.json +138 -0
- package/src/frames/official/mug-refill.json +125 -0
- package/src/frames/official/museum-plaque-light.json +187 -0
- package/src/frames/official/museum-plaque.json +187 -0
- package/src/frames/official/music-player-light.json +151 -0
- package/src/frames/official/music-player.json +136 -0
- package/src/frames/official/octagon-light.json +126 -0
- package/src/frames/official/octagon-sign.json +120 -0
- package/src/frames/official/open-book.json +156 -0
- package/src/frames/official/parking-meter.json +107 -0
- package/src/frames/official/passport-stamp.json +132 -0
- package/src/frames/official/pizza-box.json +122 -0
- package/src/frames/official/polka-dot-border.json +502 -0
- package/src/frames/official/popcorn-bucket.json +305 -0
- package/src/frames/official/porthole.json +264 -0
- package/src/frames/official/raised-card-thin.json +111 -0
- package/src/frames/official/raised-card.json +99 -0
- package/src/frames/official/retro-radio.json +180 -0
- package/src/frames/official/ribbon-top-light.json +125 -0
- package/src/frames/official/ribbon-top.json +113 -0
- package/src/frames/official/robot-chest.json +197 -0
- package/src/frames/official/roll-up-banner-light.json +137 -0
- package/src/frames/official/roll-up-banner.json +125 -0
- package/src/frames/official/round-tag-light.json +86 -0
- package/src/frames/official/round-tag.json +79 -0
- package/src/frames/official/sailboat-sail.json +99 -0
- package/src/frames/official/scroll-story.json +184 -0
- package/src/frames/official/sketch-border.json +92 -0
- package/src/frames/official/sketch-circle.json +57 -0
- package/src/frames/official/snow-globe.json +170 -0
- package/src/frames/official/soda-can.json +160 -0
- package/src/frames/official/spin-rays.json +126 -0
- package/src/frames/official/spiral-notebook.json +476 -0
- package/src/frames/official/stage-curtains.json +303 -0
- package/src/frames/official/starburst-light.json +128 -0
- package/src/frames/official/starburst.json +118 -0
- package/src/frames/official/swirl-border.json +122 -0
- package/src/frames/official/tablet-screen.json +130 -0
- package/src/frames/official/text-frame.json +79 -0
- package/src/frames/official/toaster-toast.json +114 -0
- package/src/frames/official/train-window.json +176 -0
- package/src/frames/official/treasure-map.json +207 -0
- package/src/frames/official/tv-set.json +256 -0
- package/src/frames/official/vending-machine.json +218 -0
- package/src/frames/official/video-player.json +118 -0
- package/src/frames/official/video-tape.json +137 -0
- package/src/frames/official/vinyl-sleeve-light.json +139 -0
- package/src/frames/official/vinyl-sleeve.json +127 -0
- package/src/frames/official/washing-machine.json +146 -0
- package/src/frames/official-types.ts +3 -1
- package/src/frames/official.ts +4 -3
- package/src/gif.ts +188 -0
- package/src/helpers.ts +12 -0
- package/src/ico.ts +55 -0
- package/src/index.tsx +2 -0
- package/src/looks.ts +467 -0
- package/src/plain.tsx +6 -0
- package/src/print.ts +12 -0
- package/src/qr-code-canvas.tsx +23 -2
- package/src/qr-code-props.ts +22 -0
- package/src/qr-frame-svg.tsx +26 -0
- package/src/scan-score.ts +38 -6
- package/src/utils/gif.ts +632 -0
- package/src/utils/ico.ts +150 -0
- package/src/utils/parse-color.ts +163 -23
- package/src/utils/print-shared.ts +25 -1
- package/src/utils/svg-painter.ts +18 -0
- package/src/utils.tsx +136 -17
- package/src/vanilla-api.ts +2 -2
- package/src/vue.ts +7 -1
- package/types/constants.ts +47 -0
- package/types/plain.ts +19 -0
- package/types/qr.ts +98 -0
- package/types/react.ts +11 -1
- package/types/schemas.ts +5 -0
package/src/vue.ts
CHANGED
|
@@ -81,6 +81,12 @@ const svgProps = {
|
|
|
81
81
|
moduleScale: Number,
|
|
82
82
|
autoLevel: flag,
|
|
83
83
|
shape: null,
|
|
84
|
+
eyeShapes: null,
|
|
85
|
+
eyeGradient: null,
|
|
86
|
+
bgRadius: Number,
|
|
87
|
+
backdrop: null,
|
|
88
|
+
halo: null,
|
|
89
|
+
shadow: null,
|
|
84
90
|
frameLabelMarkers: flag,
|
|
85
91
|
partMarkers: flag,
|
|
86
92
|
} as const;
|
|
@@ -168,7 +174,7 @@ export interface UseQRCodeReturn {
|
|
|
168
174
|
readonly options: ComputedRef<QRSVGOptions>;
|
|
169
175
|
/** The code's SVG markup, as `toSVGString` writes it; follows the props */
|
|
170
176
|
readonly svg: ComputedRef<string>;
|
|
171
|
-
/** The code as a data URL: "png" (default), "jpg", "webp", "bmp", "svg", "pdf" or "eps" */
|
|
177
|
+
/** The code as a data URL: "png" (default), "jpg", "webp", "bmp", "ico", "gif", "svg", "pdf" or "eps" */
|
|
172
178
|
toDataURL(
|
|
173
179
|
format?: DownloadFormat,
|
|
174
180
|
options?: QRCodeExportOptions
|
package/types/constants.ts
CHANGED
|
@@ -220,3 +220,50 @@ export const QR_SILHOUETTE_MIN_SHARE = 0.42;
|
|
|
220
220
|
|
|
221
221
|
/** The three finder patterns, for per-eye colors. */
|
|
222
222
|
export const EYE_POSITIONS = ["topLeft", "topRight", "bottomLeft"] as const;
|
|
223
|
+
|
|
224
|
+
// ── Looks around the code (qr.ts: bgRadius, backdrop, halo, shadow) ────────
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Largest `bgRadius`: the background's corner radius as a share of the
|
|
228
|
+
* code's width (0.5 rounds it into a disc). The engine also caps it so the
|
|
229
|
+
* symbol keeps its quiet zone: at most BG_RADIUS_QUIET_RATIO × `margin`
|
|
230
|
+
* modules (the arc then never reaches the finder rows), so a code with no
|
|
231
|
+
* margin keeps square corners.
|
|
232
|
+
*/
|
|
233
|
+
export const BG_RADIUS_MAX = 0.5;
|
|
234
|
+
export const BG_RADIUS_QUIET_RATIO = 2;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* A halo is a light rim around every dark module and eye (`halo`); its
|
|
238
|
+
* width is in modules. It is a look, not a quiet zone: decoders still need
|
|
239
|
+
* `margin`. It is drawn only on an opaque background, in a rim at least as
|
|
240
|
+
* light as HALO_LIGHT_MIN and no lighter than the background (looks.ts
|
|
241
|
+
* getHaloRisk). The default rim is a light grey, so it shows on white.
|
|
242
|
+
*/
|
|
243
|
+
export const HALO_WIDTH_MIN = 0.1;
|
|
244
|
+
export const HALO_WIDTH_MAX = 0.5;
|
|
245
|
+
export const HALO_WIDTH_DEFAULT = 0.25;
|
|
246
|
+
export const HALO_COLOR_DEFAULT = "#e5e7eb";
|
|
247
|
+
/** The darkest rim (and so background) a halo is drawn with. */
|
|
248
|
+
export const HALO_LIGHT_MIN = "#d1d5db";
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* A shadow is a see-through copy of the dark modules and eyes drawn under
|
|
252
|
+
* them, shifted by `dx` and `dy` modules (`shadow`). Shifts and opacity are
|
|
253
|
+
* capped where every body shape still decodes through the camera model
|
|
254
|
+
* (tests/customize-options.test.ts).
|
|
255
|
+
*/
|
|
256
|
+
export const SHADOW_OFFSET_MAX = 0.3;
|
|
257
|
+
export const SHADOW_OFFSET_DEFAULT = 0.2;
|
|
258
|
+
export const SHADOW_OPACITY_MIN = 0.1;
|
|
259
|
+
export const SHADOW_OPACITY_MAX = 0.4;
|
|
260
|
+
export const SHADOW_OPACITY_DEFAULT = 0.3;
|
|
261
|
+
export const SHADOW_COLOR_DEFAULT = "#000000";
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Where an eye's gradient runs (`eyeGradient`): "corner" sweeps each eye on
|
|
265
|
+
* its own (the default, as before); "code" lays the eyes' gradients over
|
|
266
|
+
* the whole code, like the dots', so eyes that share the dots' gradient
|
|
267
|
+
* continue it.
|
|
268
|
+
*/
|
|
269
|
+
export const EYE_GRADIENT_SPANS = ["corner", "code"] as const;
|
package/types/plain.ts
CHANGED
|
@@ -35,15 +35,23 @@ export {
|
|
|
35
35
|
export type { Excavation, Modules } from "./common";
|
|
36
36
|
export {
|
|
37
37
|
AUTO_LEVEL_LOGO_COVERAGE,
|
|
38
|
+
BG_RADIUS_MAX,
|
|
39
|
+
BG_RADIUS_QUIET_RATIO,
|
|
38
40
|
BODY_PATTERN,
|
|
39
41
|
CORNER_EYE_DOT_PATTERNS,
|
|
40
42
|
CORNER_EYE_PATTERNS,
|
|
41
43
|
DEFAULT_FRAME_TEXT,
|
|
44
|
+
EYE_GRADIENT_SPANS,
|
|
42
45
|
EYE_POSITIONS,
|
|
43
46
|
FRAME_FONT_SCALE_MAX,
|
|
44
47
|
FRAME_FONT_SCALE_MIN,
|
|
45
48
|
FRAME_STYLES,
|
|
46
49
|
FRAME_TEXT_MAX_LENGTH,
|
|
50
|
+
HALO_COLOR_DEFAULT,
|
|
51
|
+
HALO_LIGHT_MIN,
|
|
52
|
+
HALO_WIDTH_DEFAULT,
|
|
53
|
+
HALO_WIDTH_MAX,
|
|
54
|
+
HALO_WIDTH_MIN,
|
|
47
55
|
LOGO_PADDING_MAX,
|
|
48
56
|
LOGO_SHAPES,
|
|
49
57
|
LOGO_SIZE_DEFAULT,
|
|
@@ -61,6 +69,12 @@ export {
|
|
|
61
69
|
QR_SILHOUETTE_MIN_SHARE,
|
|
62
70
|
RETIRED_CORNER_EYE_DOT_PATTERNS,
|
|
63
71
|
RETIRED_CORNER_EYE_PATTERNS,
|
|
72
|
+
SHADOW_COLOR_DEFAULT,
|
|
73
|
+
SHADOW_OFFSET_DEFAULT,
|
|
74
|
+
SHADOW_OFFSET_MAX,
|
|
75
|
+
SHADOW_OPACITY_DEFAULT,
|
|
76
|
+
SHADOW_OPACITY_MAX,
|
|
77
|
+
SHADOW_OPACITY_MIN,
|
|
64
78
|
} from "./constants";
|
|
65
79
|
export type {
|
|
66
80
|
CornerEyeDotPattern,
|
|
@@ -97,12 +111,17 @@ export type {
|
|
|
97
111
|
ErrorLevel,
|
|
98
112
|
EyeColorOverride,
|
|
99
113
|
EyeColors,
|
|
114
|
+
EyeGradientSpan,
|
|
100
115
|
EyePosition,
|
|
116
|
+
EyeShapeOverride,
|
|
117
|
+
EyeShapes,
|
|
101
118
|
ImageSettings,
|
|
102
119
|
LogoOptions,
|
|
103
120
|
LogoShape,
|
|
104
121
|
QRCodeShape,
|
|
122
|
+
QRHalo,
|
|
105
123
|
QRProps,
|
|
124
|
+
QRShadow,
|
|
106
125
|
QRShape,
|
|
107
126
|
QRSilhouette,
|
|
108
127
|
QRStyle,
|
package/types/qr.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { z } from "zod";
|
|
|
3
3
|
import { type QRArt, qrArtSchema } from "./art";
|
|
4
4
|
import { type ColorConfig, colorConfigSchema } from "./color";
|
|
5
5
|
import {
|
|
6
|
+
BG_RADIUS_MAX,
|
|
7
|
+
EYE_GRADIENT_SPANS,
|
|
6
8
|
type EYE_POSITIONS,
|
|
9
|
+
HALO_WIDTH_MAX,
|
|
10
|
+
HALO_WIDTH_MIN,
|
|
7
11
|
LOGO_PADDING_MAX,
|
|
8
12
|
LOGO_SHAPES,
|
|
9
13
|
LOGO_SIZE_MAX,
|
|
@@ -13,6 +17,9 @@ import {
|
|
|
13
17
|
QR_SHAPES,
|
|
14
18
|
QR_SILHOUETTE_MAX_CELLS,
|
|
15
19
|
QR_SILHOUETTE_MIN_CELLS,
|
|
20
|
+
SHADOW_OFFSET_MAX,
|
|
21
|
+
SHADOW_OPACITY_MAX,
|
|
22
|
+
SHADOW_OPACITY_MIN,
|
|
16
23
|
} from "./constants";
|
|
17
24
|
import {
|
|
18
25
|
type CornerEyeDotPattern,
|
|
@@ -25,7 +32,14 @@ import type { TemplateDefinition } from "./template";
|
|
|
25
32
|
|
|
26
33
|
export {
|
|
27
34
|
AUTO_LEVEL_LOGO_COVERAGE,
|
|
35
|
+
BG_RADIUS_MAX,
|
|
36
|
+
BG_RADIUS_QUIET_RATIO,
|
|
37
|
+
EYE_GRADIENT_SPANS,
|
|
28
38
|
EYE_POSITIONS,
|
|
39
|
+
HALO_COLOR_DEFAULT,
|
|
40
|
+
HALO_WIDTH_DEFAULT,
|
|
41
|
+
HALO_WIDTH_MAX,
|
|
42
|
+
HALO_WIDTH_MIN,
|
|
29
43
|
LOGO_PADDING_MAX,
|
|
30
44
|
LOGO_SHAPES,
|
|
31
45
|
LOGO_SIZE_DEFAULT,
|
|
@@ -38,6 +52,12 @@ export {
|
|
|
38
52
|
QR_SILHOUETTE_MAX_CELLS,
|
|
39
53
|
QR_SILHOUETTE_MIN_CELLS,
|
|
40
54
|
QR_SILHOUETTE_MIN_SHARE,
|
|
55
|
+
SHADOW_COLOR_DEFAULT,
|
|
56
|
+
SHADOW_OFFSET_DEFAULT,
|
|
57
|
+
SHADOW_OFFSET_MAX,
|
|
58
|
+
SHADOW_OPACITY_DEFAULT,
|
|
59
|
+
SHADOW_OPACITY_MAX,
|
|
60
|
+
SHADOW_OPACITY_MIN,
|
|
41
61
|
} from "./constants";
|
|
42
62
|
|
|
43
63
|
export const logoShapeSchema = z.enum(LOGO_SHAPES);
|
|
@@ -143,6 +163,52 @@ export const eyeColorsSchema = z.object({
|
|
|
143
163
|
bottomLeft: eyeColorOverrideSchema.optional(),
|
|
144
164
|
});
|
|
145
165
|
|
|
166
|
+
/** Shapes of one eye: `outer` is the frame, `inner` the centre. */
|
|
167
|
+
export const eyeShapeOverrideSchema = z.object({
|
|
168
|
+
outer: cornerEyePatternSchema.optional(),
|
|
169
|
+
inner: cornerEyeDotPatternSchema.optional(),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/** Per-eye overrides of `cornerEyePattern` (outer) and `cornerEyeDotPattern` (inner). */
|
|
173
|
+
export const eyeShapesSchema = z.object({
|
|
174
|
+
topLeft: eyeShapeOverrideSchema.optional(),
|
|
175
|
+
topRight: eyeShapeOverrideSchema.optional(),
|
|
176
|
+
bottomLeft: eyeShapeOverrideSchema.optional(),
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
/** Where an eye's gradient runs: around its own corner, or across the code. */
|
|
180
|
+
export const eyeGradientSpanSchema = z.enum(EYE_GRADIENT_SPANS);
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A light rim around every dark module and eye. `width` is in modules
|
|
184
|
+
* (HALO_WIDTH_MIN to HALO_WIDTH_MAX, default HALO_WIDTH_DEFAULT); `color`
|
|
185
|
+
* is a solid color (default HALO_COLOR_DEFAULT, #e5e7eb), drawn opaque
|
|
186
|
+
* (its alpha is dropped). Drawn only on an opaque background, in a color at
|
|
187
|
+
* least as light as HALO_LIGHT_MIN and no lighter than the background
|
|
188
|
+
* (getHaloRisk says why not otherwise).
|
|
189
|
+
*/
|
|
190
|
+
export const haloSchema = z.object({
|
|
191
|
+
color: z.string().optional(),
|
|
192
|
+
width: z.number().min(HALO_WIDTH_MIN).max(HALO_WIDTH_MAX).optional(),
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* A see-through copy of the dark modules and eyes under them, shifted by
|
|
197
|
+
* `dx` and `dy` modules (−SHADOW_OFFSET_MAX to SHADOW_OFFSET_MAX, default
|
|
198
|
+
* SHADOW_OFFSET_DEFAULT each), in a solid `color` (default black) at
|
|
199
|
+
* `opacity` (SHADOW_OPACITY_MIN to SHADOW_OPACITY_MAX).
|
|
200
|
+
*/
|
|
201
|
+
export const shadowSchema = z.object({
|
|
202
|
+
color: z.string().optional(),
|
|
203
|
+
opacity: z
|
|
204
|
+
.number()
|
|
205
|
+
.min(SHADOW_OPACITY_MIN)
|
|
206
|
+
.max(SHADOW_OPACITY_MAX)
|
|
207
|
+
.optional(),
|
|
208
|
+
dx: z.number().min(-SHADOW_OFFSET_MAX).max(SHADOW_OFFSET_MAX).optional(),
|
|
209
|
+
dy: z.number().min(-SHADOW_OFFSET_MAX).max(SHADOW_OFFSET_MAX).optional(),
|
|
210
|
+
});
|
|
211
|
+
|
|
146
212
|
export const qrPropsSchema = z.object({
|
|
147
213
|
value: z.string(),
|
|
148
214
|
size: z.number().optional(),
|
|
@@ -169,6 +235,12 @@ export const qrPropsSchema = z.object({
|
|
|
169
235
|
.optional(),
|
|
170
236
|
autoLevel: z.boolean().optional(),
|
|
171
237
|
shape: qrCodeShapeSchema.optional(),
|
|
238
|
+
eyeShapes: eyeShapesSchema.optional(),
|
|
239
|
+
eyeGradient: eyeGradientSpanSchema.optional(),
|
|
240
|
+
bgRadius: z.number().min(0).max(BG_RADIUS_MAX).optional(),
|
|
241
|
+
backdrop: z.string().optional(),
|
|
242
|
+
halo: haloSchema.optional(),
|
|
243
|
+
shadow: shadowSchema.optional(),
|
|
172
244
|
});
|
|
173
245
|
|
|
174
246
|
// Inferred types
|
|
@@ -176,6 +248,11 @@ export type ImageSettings = z.infer<typeof imageSettingsSchema>;
|
|
|
176
248
|
export type ErrorLevel = z.infer<typeof errorLevelSchema>;
|
|
177
249
|
export type EyeColorOverride = z.infer<typeof eyeColorOverrideSchema>;
|
|
178
250
|
export type EyeColors = z.infer<typeof eyeColorsSchema>;
|
|
251
|
+
export type EyeShapeOverride = z.infer<typeof eyeShapeOverrideSchema>;
|
|
252
|
+
export type EyeShapes = z.infer<typeof eyeShapesSchema>;
|
|
253
|
+
export type EyeGradientSpan = z.infer<typeof eyeGradientSpanSchema>;
|
|
254
|
+
export type QRHalo = z.infer<typeof haloSchema>;
|
|
255
|
+
export type QRShadow = z.infer<typeof shadowSchema>;
|
|
179
256
|
|
|
180
257
|
export interface QRProps {
|
|
181
258
|
value: string;
|
|
@@ -215,6 +292,27 @@ export interface QRProps {
|
|
|
215
292
|
// decorative modules (see QR_SHAPES); a QRSilhouette fills an outline of
|
|
216
293
|
// your own. Ignored with a template.
|
|
217
294
|
shape?: QRCodeShape;
|
|
295
|
+
// Per-eye shapes; each overrides cornerEyePattern (outer) /
|
|
296
|
+
// cornerEyeDotPattern (inner) on that eye only
|
|
297
|
+
eyeShapes?: EyeShapes;
|
|
298
|
+
// Where the eyes' gradients run: "corner" (default) sweeps each eye on its
|
|
299
|
+
// own; "code" lays them over the whole code like the dots' gradient, so
|
|
300
|
+
// eyes that share the dots' gradient continue it
|
|
301
|
+
eyeGradient?: EyeGradientSpan;
|
|
302
|
+
// Corner radius of the background, as a share of the code's width (0 to
|
|
303
|
+
// BG_RADIUS_MAX; 0.5 is a disc). Capped so the symbol keeps its quiet
|
|
304
|
+
// zone (BG_RADIUS_QUIET_RATIO × margin modules). Square codes only: a
|
|
305
|
+
// shaped code (circle, heart, silhouette) has its own outline.
|
|
306
|
+
bgRadius?: number;
|
|
307
|
+
// Solid color outside the rounded background (see-through by default);
|
|
308
|
+
// drawn only when bgRadius rounds a corner
|
|
309
|
+
backdrop?: string;
|
|
310
|
+
// A light rim around the dark modules and eyes, on a light opaque
|
|
311
|
+
// background (see QRHalo). A look, not a quiet zone.
|
|
312
|
+
halo?: QRHalo;
|
|
313
|
+
// A see-through copy of the dark modules and eyes under them, shifted a
|
|
314
|
+
// fraction of a module (see QRShadow)
|
|
315
|
+
shadow?: QRShadow;
|
|
218
316
|
// For editors drawing a live preview: marks each frame label <text> with
|
|
219
317
|
// data-qrdx-frame-label (its FrameLabel.field). Off by default, and every
|
|
220
318
|
// export (getQRAsSVGDataUri and the PNG, JPG, PDF and EPS built on it)
|
package/types/react.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Prop types of the React components. Only the React entry (and the
|
|
2
2
|
// `qrdx/types` entry, for compatibility) reach this file; the core's types
|
|
3
3
|
// never do, so they work without React's types installed.
|
|
4
|
-
import type { CanvasHTMLAttributes, SVGProps } from "react";
|
|
4
|
+
import type { CanvasHTMLAttributes, ReactElement, SVGProps } from "react";
|
|
5
|
+
import type { FrameTreeOptions } from "../src/frame";
|
|
5
6
|
import type { QRCodeProps } from "../src/qr-code-props";
|
|
6
7
|
import type { QRProps } from "./qr";
|
|
7
8
|
|
|
@@ -12,3 +13,12 @@ export type QRPropsSVG = QRProps & SVGProps<SVGSVGElement>;
|
|
|
12
13
|
* SVG attributes, which go on the `<svg>` as with `QRCodeSVG`.
|
|
13
14
|
*/
|
|
14
15
|
export type QRCodePropsSVG = QRCodeProps & SVGProps<SVGSVGElement>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `QRFrameSVG`'s props: the frame, the code size it's laid out around and
|
|
19
|
+
* the code's background, an optional element for the code's slot, and SVG
|
|
20
|
+
* attributes for the outer `<svg>`.
|
|
21
|
+
*/
|
|
22
|
+
export type QRFrameSVGProps = Omit<FrameTreeOptions, "slot" | "svgProps"> & {
|
|
23
|
+
slot?: ReactElement;
|
|
24
|
+
} & Omit<SVGProps<SVGSVGElement>, "children" | "slot">;
|
package/types/schemas.ts
CHANGED
|
@@ -47,6 +47,10 @@ export {
|
|
|
47
47
|
errorLevelSchema,
|
|
48
48
|
eyeColorOverrideSchema,
|
|
49
49
|
eyeColorsSchema,
|
|
50
|
+
eyeGradientSpanSchema,
|
|
51
|
+
eyeShapeOverrideSchema,
|
|
52
|
+
eyeShapesSchema,
|
|
53
|
+
haloSchema,
|
|
50
54
|
imageSettingsSchema,
|
|
51
55
|
logoOptionsSchema,
|
|
52
56
|
logoShapeSchema,
|
|
@@ -54,6 +58,7 @@ export {
|
|
|
54
58
|
qrPropsSchema,
|
|
55
59
|
qrShapeSchema,
|
|
56
60
|
qrSilhouetteSchema,
|
|
61
|
+
shadowSchema,
|
|
57
62
|
} from "./qr";
|
|
58
63
|
export {
|
|
59
64
|
baseTemplatePropsSchema,
|