qrdx 0.0.46 → 0.0.48
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 +358 -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 +50 -6
- 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 +25 -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/webp.d.ts +25 -0
- package/dist/src/utils/webp.d.ts.map +1 -0
- package/dist/src/utils.d.ts +18 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/webp.d.ts +19 -0
- package/dist/src/webp.d.ts.map +1 -0
- 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 +70 -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 +174 -70
- 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 +150 -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/webp.ts +556 -0
- package/src/utils.tsx +794 -385
- package/src/webp.ts +84 -0
- 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,50 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: frame proportions */
|
|
2
|
+
import type { FrameStyle, QRFrame } from "../types";
|
|
3
|
+
import type { FrameLabel, FrameLayout } from "./frame";
|
|
4
|
+
export declare const SHAPED_FRAME_STYLES: readonly ["banner-top-bottom", "speech-bubble-top", "chat-bubble", "circle", "polaroid", "phone", "ticket", "badge", "envelope", "tag", "menu-card", "sticker", "gradient-border", "focus"];
|
|
5
|
+
export type ShapedFrameStyle = (typeof SHAPED_FRAME_STYLES)[number];
|
|
6
|
+
export declare function isShapedFrameStyle(style: FrameStyle): style is ShapedFrameStyle;
|
|
7
|
+
/** Default colors of "gradient-border" when `color` / `secondaryColor` are unset. */
|
|
8
|
+
export declare const GRADIENT_FRAME_DEFAULTS: {
|
|
9
|
+
from: string;
|
|
10
|
+
to: string;
|
|
11
|
+
};
|
|
12
|
+
/** Rough em width of one character in a bold sans-serif. */
|
|
13
|
+
export declare function charEm(char: string): number;
|
|
14
|
+
export declare function estimateTextEm(text: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* Opaque mix of two colors (`amount` 0 = `from`, 1 = `to`). Frames use solid
|
|
17
|
+
* tints instead of transparency, because EPS has no transparency.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mixFrameColors(from: string, to: string, amount: number): string;
|
|
20
|
+
export interface FrameStyleContext {
|
|
21
|
+
/** Width of the QR code (margin included) */
|
|
22
|
+
size: number;
|
|
23
|
+
frame: QRFrame;
|
|
24
|
+
/** Frame color (`frame.color` or black) */
|
|
25
|
+
color: string;
|
|
26
|
+
/** Solid page color behind the code */
|
|
27
|
+
background: string;
|
|
28
|
+
text: string;
|
|
29
|
+
secondaryText: string;
|
|
30
|
+
gap: number;
|
|
31
|
+
border: number;
|
|
32
|
+
band: number;
|
|
33
|
+
fontScale: number;
|
|
34
|
+
/**
|
|
35
|
+
* Label fitted in a row: font from the row height, shrunk to `maxWidth`.
|
|
36
|
+
* `field` is the frame text it draws ("text" unless given).
|
|
37
|
+
*/
|
|
38
|
+
fitLabel: (text: string, centerX: number, centerY: number, rowHeight: number, maxWidth: number, color: string, field?: "text" | "secondaryText") => FrameLabel | null;
|
|
39
|
+
}
|
|
40
|
+
type Layout = (ctx: FrameStyleContext) => FrameLayout;
|
|
41
|
+
/**
|
|
42
|
+
* Letters of `text` set along a circle of `radius` around (cx, cy): over the
|
|
43
|
+
* top reading clockwise, or along the bottom reading left to right, upright.
|
|
44
|
+
*/
|
|
45
|
+
export declare function arcLabels(text: string, cx: number, cy: number, radius: number, fontSize: number, where: "top" | "bottom", color: string,
|
|
46
|
+
/** The frame text the letters draw (FrameLabel.field) */
|
|
47
|
+
field: string): FrameLabel[];
|
|
48
|
+
export declare const SHAPED_FRAMES: Record<ShapedFrameStyle, Layout>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=frame-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-styles.d.ts","sourceRoot":"","sources":["../../src/frame-styles.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAKpE,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAEV,UAAU,EACV,WAAW,EAIZ,MAAM,SAAS,CAAC;AAKjB,eAAO,MAAM,mBAAmB,6LAeU,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,GAChB,KAAK,IAAI,gBAAgB,CAE3B;AAED,qFAAqF;AACrF,eAAO,MAAM,uBAAuB;;;CAAqC,CAAC;AAM1E,4DAA4D;AAC5D,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAc3C;AAID,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMnD;AASD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AA6CD,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GAAG,eAAe,KAC7B,UAAU,GAAG,IAAI,CAAC;CACxB;AAED,KAAK,MAAM,GAAG,CAAC,GAAG,EAAE,iBAAiB,KAAK,WAAW,CAAC;AA2ItD;;;GAGG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,KAAK,GAAG,QAAQ,EACvB,KAAK,EAAE,MAAM;AACb,yDAAyD;AACzD,KAAK,EAAE,MAAM,GACZ,UAAU,EAAE,CAoCd;AA+sBD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAe1D,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: frame proportions */
|
|
2
|
+
import type { ReactElement, SVGProps } from "react";
|
|
3
|
+
import type { ColorConfig } from "../types";
|
|
4
|
+
import { type AnyQRFrame } from "../types/frame-spec";
|
|
5
|
+
/** System font stack for frame labels, so rendering never fetches a font. */
|
|
6
|
+
export declare const FRAME_FONT_FAMILY = "system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif";
|
|
7
|
+
/** Light gap between the code and the frame, as a share of the code width */
|
|
8
|
+
export declare const FRAME_GAP_RATIO = 0.08;
|
|
9
|
+
export interface FrameBox {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
radius: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FrameRect extends FrameBox {
|
|
17
|
+
type: "rect";
|
|
18
|
+
fill: string;
|
|
19
|
+
/** Area cut out of the rect (where the QR code shows through) */
|
|
20
|
+
hole?: FrameBox;
|
|
21
|
+
}
|
|
22
|
+
export interface FramePolygon {
|
|
23
|
+
type: "polygon";
|
|
24
|
+
points: [number, number][];
|
|
25
|
+
fill: string;
|
|
26
|
+
}
|
|
27
|
+
/** Any outline, as SVG path data in artwork coordinates. */
|
|
28
|
+
export interface FramePath {
|
|
29
|
+
type: "path";
|
|
30
|
+
d: string;
|
|
31
|
+
fill: string;
|
|
32
|
+
/** "evenodd" turns inner subpaths into holes */
|
|
33
|
+
fillRule?: "nonzero" | "evenodd";
|
|
34
|
+
}
|
|
35
|
+
export type FrameShape = FrameRect | FramePolygon | FramePath;
|
|
36
|
+
export interface FrameLabel {
|
|
37
|
+
text: string;
|
|
38
|
+
/** Horizontal center of the label (its left or right end with `align`) */
|
|
39
|
+
x: number;
|
|
40
|
+
/** Alphabetic baseline of the label */
|
|
41
|
+
y: number;
|
|
42
|
+
fontSize: number;
|
|
43
|
+
/** Width the label must fit in */
|
|
44
|
+
maxWidth: number;
|
|
45
|
+
color: string;
|
|
46
|
+
/** Clockwise rotation in degrees around (x, y), for text set on a curve */
|
|
47
|
+
rotate?: number;
|
|
48
|
+
/** Which end of the text `x` is (default "middle") */
|
|
49
|
+
align?: "start" | "middle" | "end";
|
|
50
|
+
/** CSS font weight (default 700); PDF and EPS draw 600+ as bold */
|
|
51
|
+
fontWeight?: number;
|
|
52
|
+
/**
|
|
53
|
+
* The frame text this label draws: "text", "secondaryText", or a custom
|
|
54
|
+
* spec's label id. Every letter of curved text carries its label's field.
|
|
55
|
+
* Editors find a label by it (see `frameLabelMarkers`).
|
|
56
|
+
*/
|
|
57
|
+
field?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Attribute that marks frame labels in SVG drawn with `frameLabelMarkers`. */
|
|
60
|
+
export declare const FRAME_LABEL_ATTRIBUTE = "data-qrdx-frame-label";
|
|
61
|
+
export interface FrameLayout {
|
|
62
|
+
/** Full artwork width (frame included) */
|
|
63
|
+
width: number;
|
|
64
|
+
/** Full artwork height (frame included) */
|
|
65
|
+
height: number;
|
|
66
|
+
/** Where the QR code (with its own margin) sits inside the artwork */
|
|
67
|
+
qrX: number;
|
|
68
|
+
qrY: number;
|
|
69
|
+
qrSize: number;
|
|
70
|
+
/** Shapes painted behind the QR code, in order */
|
|
71
|
+
shapes: FrameShape[];
|
|
72
|
+
label: FrameLabel | null;
|
|
73
|
+
/** Further labels (a second line, or the letters of curved text) */
|
|
74
|
+
extraLabels?: FrameLabel[];
|
|
75
|
+
/** True when the frame fills its whole bounding box (no rounded corners) */
|
|
76
|
+
squareEdges: boolean;
|
|
77
|
+
/** Frame color, for print bleed */
|
|
78
|
+
color: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* True when `frame` draws something. A "custom" frame counts even when its
|
|
82
|
+
* spec is invalid: drawing it then throws a FrameSpecError instead of
|
|
83
|
+
* leaving the frame out silently.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isFrameActive(frame: AnyQRFrame | null | undefined): frame is AnyQRFrame;
|
|
86
|
+
/**
|
|
87
|
+
* Light gap the frame keeps around the code, as a share of the code width
|
|
88
|
+
* (FRAME_GAP_RATIO for the built-in frames, the plate padding for custom).
|
|
89
|
+
*/
|
|
90
|
+
export declare function getFrameGapRatio(frame: AnyQRFrame): number;
|
|
91
|
+
/** The label a frame renders: trimmed and capped at 24 characters. */
|
|
92
|
+
export declare function getFrameText(frame: AnyQRFrame): string;
|
|
93
|
+
/** The second label (no default), trimmed and capped at 24 characters. */
|
|
94
|
+
export declare function getFrameSecondaryText(frame: AnyQRFrame): string;
|
|
95
|
+
/**
|
|
96
|
+
* Computes where the frame shapes, label and QR code go for a code of `size`
|
|
97
|
+
* pixels. The QR code keeps its full size; the frame is added around it.
|
|
98
|
+
* A "custom" frame is drawn from its spec (throws a FrameSpecError when the
|
|
99
|
+
* spec is invalid).
|
|
100
|
+
*/
|
|
101
|
+
export declare function getFrameLayout(size: number, frame: AnyQRFrame, bgColor?: ColorConfig): FrameLayout;
|
|
102
|
+
/**
|
|
103
|
+
* Output dimensions for a code of `size` pixels with `frame` applied
|
|
104
|
+
* (`size × size` when there is no frame).
|
|
105
|
+
*/
|
|
106
|
+
export declare function getFrameDimensions(size: number, frame?: AnyQRFrame | null): {
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Wraps a rendered QR `<svg>` (sized `size × size`) in a frame. The QR element
|
|
112
|
+
* is nested as-is at its offset, so its modules are untouched.
|
|
113
|
+
*/
|
|
114
|
+
export declare function wrapWithFrame(qrElement: ReactElement<SVGProps<SVGSVGElement>>, options: {
|
|
115
|
+
size: number;
|
|
116
|
+
frame: AnyQRFrame;
|
|
117
|
+
bgColor?: ColorConfig;
|
|
118
|
+
svgProps?: SVGProps<SVGSVGElement>;
|
|
119
|
+
/** Mark each label with FRAME_LABEL_ATTRIBUTE (its `field`), for editors */
|
|
120
|
+
markLabels?: boolean;
|
|
121
|
+
}): ReactElement;
|
|
122
|
+
/** Every label of a layout: the main one first, then the extra ones. */
|
|
123
|
+
export declare function frameLabels(layout: FrameLayout): FrameLabel[];
|
|
124
|
+
/** Paints the frame shapes and label on a 2D canvas (QR code not included). */
|
|
125
|
+
export declare function drawFrameOnCanvas(ctx: CanvasRenderingContext2D, layout: FrameLayout): void;
|
|
126
|
+
//# sourceMappingURL=frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/frame.tsx"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAO5C,OAAO,EAAE,KAAK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GAAG,IAAI,GACxB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAMnC;AAmED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,EAChD,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,QAAQ,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACnC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA,YAAY,CA8Cd;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,EAAE,CAK7D;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,wBAAwB,EAC7B,MAAM,EAAE,WAAW,QA+DpB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FrameStyle } from "../../types/frame";
|
|
2
|
+
import type { FrameSpec } from "../../types/frame-spec";
|
|
3
|
+
/**
|
|
4
|
+
* Specs that draw the same artwork as these built-in styles (with a label
|
|
5
|
+
* set; the built-ins shrink when the label is empty, a spec doesn't).
|
|
6
|
+
*/
|
|
7
|
+
export declare const BUILT_IN_FRAME_SPECS: Partial<Record<FrameStyle, FrameSpec>>;
|
|
8
|
+
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../../src/frames/builtin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAKvE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FrameSpec } from "../../types/frame-spec";
|
|
2
|
+
export interface OfficialFrame {
|
|
3
|
+
/** Stable id (also the file name) */
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
category: "use-case" | "seasonal";
|
|
8
|
+
/** QRdx content types the frame suits (empty: any) */
|
|
9
|
+
contentTypes: string[];
|
|
10
|
+
tags: string[];
|
|
11
|
+
license: "CC0-1.0";
|
|
12
|
+
spec: FrameSpec;
|
|
13
|
+
}
|
|
14
|
+
/** The official frames, in catalogue order (use cases, then seasons). */
|
|
15
|
+
export declare const OFFICIAL_FRAMES: readonly OfficialFrame[];
|
|
16
|
+
/** An official frame by id. */
|
|
17
|
+
export declare function getOfficialFrame(id: string): OfficialFrame | undefined;
|
|
18
|
+
//# sourceMappingURL=official.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"official.d.ts","sourceRoot":"","sources":["../../../src/frames/official.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AA0BxD,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,UAAU,GAAG,UAAU,CAAC;IAClC,sDAAsD;IACtD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,yEAAyE;AAEzE,eAAO,MAAM,eAAe,EAyBZ,SAAS,aAAa,EAAE,CAAC;AAEzC,+BAA+B;AAC/B,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEtE"}
|
package/dist/src/helpers.d.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import type { QRProps } from "../types";
|
|
1
|
+
import type { LogoOptions, QRProps } from "../types";
|
|
2
2
|
interface QRDataProps extends QRProps {
|
|
3
3
|
hideLogo?: boolean;
|
|
4
4
|
logo?: string;
|
|
5
|
+
/**
|
|
6
|
+
* Size, clear space and position of `logo` (see `LogoOptions`). Without
|
|
7
|
+
* it the logo is 25% wide and centered, as before.
|
|
8
|
+
*/
|
|
9
|
+
logoOptions?: LogoOptions;
|
|
5
10
|
}
|
|
6
11
|
interface QRDataResult extends QRProps {
|
|
7
12
|
size: number;
|
|
8
13
|
}
|
|
9
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The largest logo `size` (share of the code's width, up to LOGO_SIZE_MAX)
|
|
16
|
+
* that fits this code's error correction with `options`' clear space and
|
|
17
|
+
* position, so the editor can cap its slider. 0 when no logo fits.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getLogoSizeLimit({ value, level, margin, shape, autoLevel, logoOptions, }: Pick<QRProps, "value" | "level" | "margin" | "shape" | "autoLevel"> & {
|
|
20
|
+
logoOptions?: LogoOptions;
|
|
21
|
+
}): number;
|
|
22
|
+
export declare function getQRData({ value, size, fgColor, bgColor, eyeColor, dotColor, bodyPattern, hideLogo, logo, logoOptions, margin, cornerEyePattern, cornerEyeDotPattern, level, templateId, frame, eyeColors, moduleScale, autoLevel, shape, }: QRDataProps): QRDataResult;
|
|
10
23
|
export {};
|
|
11
24
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAQhF,UAAU,WAAY,SAAQ,OAAO;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,UAAU,YAAa,SAAQ,OAAO;IACpC,IAAI,EAAE,MAAM,CAAC;CACd;AA8GD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,KAAK,EACL,MAAM,EACN,KAAK,EACL,SAAS,EACT,WAAW,GACZ,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,CAAC,GAAG;IACvE,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,GAAG,MAAM,CAST;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,IAAW,EACX,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,KAAK,GACN,EAAE,WAAW,GAAG,YAAY,CA+B5B"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
/** biome-ignore-all lint/performance/noBarrelFile: false positive */
|
|
2
2
|
/** biome-ignore-all lint/style/noMagicNumbers: false positive */
|
|
3
|
-
|
|
4
|
-
/** biome-ignore-all lint/a11y/noNoninteractiveElementInteractions: false positive */
|
|
5
|
-
/** biome-ignore-all lint/performance/noImgElement: false positive */
|
|
6
|
-
/** biome-ignore-all lint/complexity/noExcessiveCognitiveComplexity: false positive */
|
|
7
|
-
/**
|
|
8
|
-
* @license qrcode.react
|
|
9
|
-
* Copyright (c) Paul O'Shannessy
|
|
10
|
-
* SPDX-License-Identifier: ISC
|
|
11
|
-
*/
|
|
12
|
-
import { type JSX } from "react";
|
|
13
|
-
import type { QRProps, QRPropsCanvas } from "../types";
|
|
3
|
+
import type { QRProps } from "../types";
|
|
14
4
|
export * from "../types";
|
|
15
5
|
export * from "./api";
|
|
6
|
+
export { createQRArtImage, DEFAULT_ART_INTENSITY, getQRArtColorIssue, getQRArtEyeColors, getQRArtVariant, getQRFunctionModules, isQRArtActive, loadQRArtImage, QR_ART_MIN_LUMA_GAP, QR_ART_SAMPLE_SIZES, type QRArtColorIssue, type QRArtEyeColorOptions, type QRArtPixels, type QRArtRenderOptions, renderQRArt, } from "./art";
|
|
7
|
+
export { clampModuleScale, MODULE_SCALE_FLOOR } from "./body-patterns";
|
|
16
8
|
export * from "./detection";
|
|
17
9
|
export * from "./download";
|
|
10
|
+
export { downloadPrintEPS, EPS_IMAGE_FILL_REASON, type EPSOptions, epsToDataUrl, getQRAsEPS, hasImageFill, type SVGToEPSOptions, svgToEPS, } from "./eps";
|
|
11
|
+
export { FRAME_FONT_FAMILY, FRAME_GAP_RATIO, FRAME_LABEL_ATTRIBUTE, type FrameBox, type FrameLabel, type FrameLayout, type FramePath, type FramePolygon, type FrameRect, type FrameShape, frameLabels, getFrameDimensions, getFrameGapRatio, getFrameLayout, getFrameSecondaryText, getFrameText, isFrameActive, } from "./frame";
|
|
12
|
+
export { FRAME_ICON_BOX, type FrameIconPath, getFrameIconPath, } from "./frame-icons";
|
|
13
|
+
export { FRAME_IMPORT_LIMITS, type FrameImportColor, type FrameImportOptions, type FrameImportResult, type FrameImportWarning, importFrameSvg, } from "./frame-import";
|
|
14
|
+
export { FrameSpecError, getCustomFrameLayout, getFrameSpecGapRatio, resolveFrameSpec, } from "./frame-spec";
|
|
15
|
+
export { GRADIENT_FRAME_DEFAULTS, mixFrameColors } from "./frame-styles";
|
|
16
|
+
export { BUILT_IN_FRAME_SPECS } from "./frames/builtin";
|
|
17
|
+
export { getOfficialFrame, OFFICIAL_FRAMES, type OfficialFrame, } from "./frames/official";
|
|
18
|
+
export { LOGO_PLATE_INSET, LOGO_ROUNDED_RADIUS, } from "./logo";
|
|
19
|
+
export { LOGO_CLEANUP_MAX_SIDE, type LogoPixels, removeLogoBackdrop, removeLogoBackground, } from "./logo-cleanup";
|
|
20
|
+
export * from "./print";
|
|
18
21
|
export * from "./qr-code";
|
|
22
|
+
export { QRCodeCanvas } from "./qr-code-canvas";
|
|
23
|
+
export { circleQuietZone, getLayoutMargin, getQRShapePath, getQRSilhouetteFit, isShapedCode, type QRSilhouetteFit, } from "./qr-shape";
|
|
24
|
+
export { getStylePairRisk, isWeakSharpPair, SHARP_DOT_EYE_SAFE_BODIES, type StylePairRisk, WEAK_BODY_EYES, WEAK_DOT_EYES, WEAK_DOTS, WEAK_EYES, WEAK_SHARP_DOT_EYES, } from "./scan-risk";
|
|
25
|
+
export * from "./scan-score";
|
|
26
|
+
export { createQRSilhouette, loadQRSilhouette, } from "./silhouette";
|
|
19
27
|
export * from "./templates";
|
|
20
28
|
export * from "./utils";
|
|
21
|
-
|
|
29
|
+
/** Reads an 8-bit PNG into RGBA pixels (no DOM or sharp), or null. */
|
|
30
|
+
export { type DecodedImage, decodePng as decodePNGPixels } from "./utils/png";
|
|
31
|
+
export * from "./webp";
|
|
22
32
|
export declare function getQRAsSVGDataUri(props: QRProps): Promise<string>;
|
|
23
33
|
export declare function getQRAsCanvas(props: QRProps, type: string, getCanvas?: boolean): Promise<HTMLCanvasElement | string>;
|
|
24
|
-
export {
|
|
34
|
+
export { type CodewordMap, damagedCodewords, getCodewordMap, } from "./codeword-map";
|
|
35
|
+
export { getLogoSizeLimit, getQRData } from "./helpers";
|
|
36
|
+
export { getLogoBlockDamage, LOGO_EC_SAFETY, type LogoBlockDamage, logoFitsBudget, } from "./logo-budget";
|
|
25
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,iEAAiE;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,iEAAiE;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxC,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,WAAW,GACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,UAAU,EACf,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,KAAK,eAAe,EACpB,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,KAAK,gBAAgB,EACrB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AAsB,aAAa,CACjC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,iBAAiB,GAAG,MAAM,CAAC,CA2FrC;AAED,OAAO,EACL,KAAK,WAAW,EAChB,gBAAgB,EAChB,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,KAAK,eAAe,EACpB,cAAc,GACf,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: error correction budget */
|
|
2
|
+
import type { ErrorLevel, ImageSettings, QRCodeShape } from "../types";
|
|
3
|
+
/** Share of each block's repair capacity a logo may use (as the badge). */
|
|
4
|
+
export declare const LOGO_EC_SAFETY = 0.6;
|
|
5
|
+
export interface LogoBlockDamage {
|
|
6
|
+
/** Codewords the logo spoils in its worst block */
|
|
7
|
+
worst: number;
|
|
8
|
+
/** Codewords that block can repair (ISO/IEC 18004 Table 9) */
|
|
9
|
+
correctable: number;
|
|
10
|
+
/** Most the logo may spoil per block: correctable × LOGO_EC_SAFETY */
|
|
11
|
+
budget: number;
|
|
12
|
+
/** The level the symbol is really drawn at (qrcodegen may boost it) */
|
|
13
|
+
level: ErrorLevel;
|
|
14
|
+
version: number;
|
|
15
|
+
}
|
|
16
|
+
export interface LogoCode {
|
|
17
|
+
value: string;
|
|
18
|
+
/** Pixels across the artwork the logo's pixels are laid out in */
|
|
19
|
+
size: number;
|
|
20
|
+
margin: number;
|
|
21
|
+
level: ErrorLevel;
|
|
22
|
+
shape?: QRCodeShape;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Codewords `imageSettings` spoils per Reed–Solomon block of `code`: every
|
|
26
|
+
* codeword with a module inside the cleared area (or under the logo when
|
|
27
|
+
* nothing is cleared). Null when the logo falls outside the code.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getLogoBlockDamage(code: LogoCode, imageSettings: ImageSettings): LogoBlockDamage | null;
|
|
30
|
+
/** True when the logo stays inside every block's budget at `code.level`. */
|
|
31
|
+
export declare function logoFitsBudget(code: LogoCode, imageSettings: ImageSettings): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Largest logo width (pixels, up to `requested`) for which `layout(width)`
|
|
34
|
+
* fits the budget at every one of `levels` (with autoLevel the code may be
|
|
35
|
+
* drawn at its own level or at H). 0 when no width fits.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fitLogoWidth(code: Omit<LogoCode, "level">, levels: readonly ErrorLevel[], requested: number, layout: (width: number) => ImageSettings): number;
|
|
38
|
+
export interface RenderedLogoCode extends Omit<LogoCode, "level"> {
|
|
39
|
+
level?: ErrorLevel;
|
|
40
|
+
/** The renderer's autoLevel (a logo over 7% of the code raises it to H) */
|
|
41
|
+
autoLevel?: boolean;
|
|
42
|
+
/** QRCodeSVG's isOGContext (an excavated logo raises L/M to Q) */
|
|
43
|
+
isOGContext?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `imageSettings` passed straight to a renderer (QRCodeSVG, QRCodeCanvas,
|
|
47
|
+
* getQRAsSVG), held to the same budget getQRData gives `logo` +
|
|
48
|
+
* `logoOptions`: unchanged when it fits, else shrunk around its own center
|
|
49
|
+
* (aspect ratio and clear space kept) to the largest size that does, or
|
|
50
|
+
* undefined when not even a sliver fits. A logo already capped by getQRData
|
|
51
|
+
* comes back as it is.
|
|
52
|
+
*/
|
|
53
|
+
export declare function capImageSettings(code: RenderedLogoCode, imageSettings: ImageSettings | undefined): ImageSettings | undefined;
|
|
54
|
+
//# sourceMappingURL=logo-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logo-budget.d.ts","sourceRoot":"","sources":["../../src/logo-budget.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAS1E,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;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,gBAAgB,EACtB,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,aAAa,GAAG,SAAS,CAgD3B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface LogoPixels {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
/** RGBA, 4 bytes per pixel */
|
|
5
|
+
data: Uint8ClampedArray | Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Longest side the browser helper works at (larger logos are scaled down):
|
|
9
|
+
* plenty for a logo at 30% of a print, and the PNG stays small enough to
|
|
10
|
+
* save with a design.
|
|
11
|
+
*/
|
|
12
|
+
export declare const LOGO_CLEANUP_MAX_SIDE = 512;
|
|
13
|
+
/**
|
|
14
|
+
* `pixels` with the background made transparent, or null when the image has
|
|
15
|
+
* no solid background (transparent or mixed corners). Edge pixels keep
|
|
16
|
+
* their own color: the background's share is taken out as they fade.
|
|
17
|
+
*/
|
|
18
|
+
export declare function removeLogoBackdrop(pixels: LogoPixels): LogoPixels | null;
|
|
19
|
+
/**
|
|
20
|
+
* Browser: the logo at `src` (a data URL or a same-origin or CORS-enabled
|
|
21
|
+
* URL) with its solid background removed, as a PNG data URL, or null when
|
|
22
|
+
* it has none or can't be read. Logos larger than 512 px are scaled down.
|
|
23
|
+
*/
|
|
24
|
+
export declare function removeLogoBackground(src: string): Promise<string | null>;
|
|
25
|
+
//# sourceMappingURL=logo-cleanup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logo-cleanup.d.ts","sourceRoot":"","sources":["../../src/logo-cleanup.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,iBAAiB,GAAG,UAAU,CAAC;CACtC;AAOD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAmExE;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: logo geometry */
|
|
2
|
+
import type { JSX } from "react";
|
|
3
|
+
import type { ImageSettings, LogoShape } from "../types";
|
|
4
|
+
/** Rounded corners' radius, as a share of the logo's shorter side. */
|
|
5
|
+
export declare const LOGO_ROUNDED_RADIUS = 0.22;
|
|
6
|
+
/** With a plate, the logo is inset this share of the box on each side. */
|
|
7
|
+
export declare const LOGO_PLATE_INSET = 0.14;
|
|
8
|
+
interface Box {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The logo in `box` (the user units of the surrounding SVG): the image,
|
|
16
|
+
* cropped to `settings.shape`, on a `settings.plate` plate when one is set.
|
|
17
|
+
* A plain square logo is a bare <image>, exactly as before.
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderLogo(settings: Pick<ImageSettings, "src" | "shape" | "plate">, box: Box): JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* Traces `shape` filling `box` on a canvas path (for `QRCodeCanvas`), so the
|
|
22
|
+
* caller can fill it (the plate) or clip to it (the logo).
|
|
23
|
+
*/
|
|
24
|
+
export declare function traceLogoShape(ctx: CanvasRenderingContext2D, shape: LogoShape, box: Box): void;
|
|
25
|
+
/** The box the logo image fills inside `box` (inset when on a plate). */
|
|
26
|
+
export declare function logoImageBox(box: Box, plate: string | undefined): Box;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=logo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logo.d.ts","sourceRoot":"","sources":["../../src/logo.tsx"],"names":[],"mappings":"AAAA,gEAAgE;AAKhE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAIzD,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,UAAU,GAAG;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAuCD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,EACxD,GAAG,EAAE,GAAG,GACP,GAAG,CAAC,OAAO,CAmCb;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,GAAG,QAoBT;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,CAErE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { QRProps } from "../types";
|
|
2
|
+
export { type RGBAColor, rgbToCmyk } from "./utils/parse-color";
|
|
3
|
+
export type PrintUnit = "mm" | "in";
|
|
4
|
+
export type PrintColorMode = "rgb" | "cmyk";
|
|
5
|
+
export interface PrintOptions {
|
|
6
|
+
/** Width of the QR code itself, in `unit`. A frame adds to the printed size. */
|
|
7
|
+
size: number;
|
|
8
|
+
/** Unit for `size` (default "mm") */
|
|
9
|
+
unit?: PrintUnit;
|
|
10
|
+
/** Bleed on every side, in millimetres (0 by default; 3 is typical) */
|
|
11
|
+
bleed?: number;
|
|
12
|
+
/** Draw crop marks outside the bleed (default false) */
|
|
13
|
+
cropMarks?: boolean;
|
|
14
|
+
/** "cmyk" writes naive CMYK colors, see `rgbToCmyk` (default "rgb") */
|
|
15
|
+
colorMode?: PrintColorMode;
|
|
16
|
+
}
|
|
17
|
+
/** Physical layout of a print file. All lengths are in millimetres. */
|
|
18
|
+
export interface PrintLayout {
|
|
19
|
+
/** Width of the QR code, quiet zone (margin) included */
|
|
20
|
+
codeWidth: number;
|
|
21
|
+
/** Finished (trimmed) artwork size, frame included */
|
|
22
|
+
trimWidth: number;
|
|
23
|
+
trimHeight: number;
|
|
24
|
+
bleed: number;
|
|
25
|
+
/** Page size: trim + bleed (+ room for crop marks) */
|
|
26
|
+
pageWidth: number;
|
|
27
|
+
pageHeight: number;
|
|
28
|
+
/** Top-left corner of the trim box on the page */
|
|
29
|
+
trimX: number;
|
|
30
|
+
trimY: number;
|
|
31
|
+
/** Width of one QR module */
|
|
32
|
+
moduleSize: number;
|
|
33
|
+
/** Modules across the code, margin included */
|
|
34
|
+
moduleCount: number;
|
|
35
|
+
/** Rule of thumb: a code scans from about 10× its width */
|
|
36
|
+
maxScanDistance: number;
|
|
37
|
+
}
|
|
38
|
+
/** Modules across the code for these props, margin included. */
|
|
39
|
+
export declare function getQRModuleCount(props: QRProps): number;
|
|
40
|
+
/**
|
|
41
|
+
* Computes the physical size of a print file (no rendering). Throws when the
|
|
42
|
+
* size is out of range (5 mm to 2 m).
|
|
43
|
+
*/
|
|
44
|
+
export declare function getPrintLayout(props: QRProps, options: PrintOptions): PrintLayout;
|
|
45
|
+
/**
|
|
46
|
+
* Renders a print-ready vector PDF: modules, eyes and frame are vector paths
|
|
47
|
+
* (logos stay raster images) at the exact physical size, with optional bleed
|
|
48
|
+
* and crop marks. In "cmyk" mode colors are converted with `rgbToCmyk`.
|
|
49
|
+
* Linear and radial gradient fills are native PDF shadings clipped to each
|
|
50
|
+
* shape (in "cmyk" mode they blend between the converted stops); gradient
|
|
51
|
+
* strokes and text use their first color. Frame text uses Helvetica Bold, so
|
|
52
|
+
* characters outside Latin-1 may not render.
|
|
53
|
+
*
|
|
54
|
+
* Returns a `data:application/pdf` URL. Needs the optional `jspdf` package.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getQRAsPrintPDF(props: QRProps, options: PrintOptions): Promise<string>;
|
|
57
|
+
/** Same as `getQRAsPrintPDF`, but returns the PDF as an ArrayBuffer. */
|
|
58
|
+
export declare function getQRAsPrintPDFBuffer(props: QRProps, options: PrintOptions): Promise<ArrayBuffer>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the artwork as SVG markup at its physical trim size (e.g.
|
|
61
|
+
* `width="40mm"`). SVG has no CMYK, so colors stay RGB; bleed and crop marks
|
|
62
|
+
* are left to your layout tool.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getQRAsPrintSVG(props: QRProps, options: Pick<PrintOptions, "size" | "unit">): Promise<string>;
|
|
65
|
+
/** Downloads `getQRAsPrintPDF` output (browser only). */
|
|
66
|
+
export declare function downloadPrintPDF(props: QRProps, options: PrintOptions & {
|
|
67
|
+
filename?: string;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
/** Downloads `getQRAsPrintSVG` output (browser only). */
|
|
70
|
+
export declare function downloadPrintSVG(props: QRProps, options: Pick<PrintOptions, "size" | "unit"> & {
|
|
71
|
+
filename?: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
//# sourceMappingURL=print.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../src/print.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AA2CxC,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhE,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AACp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;AA2GD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,GAC3C,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED,yDAAyD;AACzD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,YAAY,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,yDAAyD;AACzD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACnE,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: false positive */
|
|
2
|
+
/** biome-ignore-all lint/correctness/useImageSize: false positive */
|
|
3
|
+
/** biome-ignore-all lint/performance/noImgElement: false positive */
|
|
4
|
+
/** biome-ignore-all lint/a11y/noNoninteractiveElementInteractions: hidden loader image */
|
|
5
|
+
/**
|
|
6
|
+
* @license qrcode.react
|
|
7
|
+
* Copyright (c) Paul O'Shannessy
|
|
8
|
+
* SPDX-License-Identifier: ISC
|
|
9
|
+
*/
|
|
10
|
+
import { type JSX } from "react";
|
|
11
|
+
import type { QRPropsCanvas } from "../types";
|
|
12
|
+
export declare function QRCodeCanvas(props: QRPropsCanvas): JSX.Element;
|
|
13
|
+
//# sourceMappingURL=qr-code-canvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-code-canvas.d.ts","sourceRoot":"","sources":["../../src/qr-code-canvas.tsx"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,qEAAqE;AACrE,qEAAqE;AACrE,0FAA0F;AAI1F;;;;GAIG;AACH,OAAO,EAAE,KAAK,GAAG,EAA+B,MAAM,OAAO,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAuB9C,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,eA4MhD"}
|
package/dist/src/qr-code.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { QRProps } from "../types";
|
|
1
|
+
import type { LogoOptions, QRProps } from "../types";
|
|
2
2
|
interface QRCodeProps extends QRProps {
|
|
3
3
|
hideLogo?: boolean;
|
|
4
4
|
logo?: string;
|
|
5
|
+
/** Size, clear space and position of `logo` (see `LogoOptions`) */
|
|
6
|
+
logoOptions?: LogoOptions;
|
|
5
7
|
scale?: number;
|
|
6
8
|
}
|
|
7
|
-
export declare const QRCode: import("react").MemoExoticComponent<({ value, fgColor, hideLogo, logo, bgColor, eyeColor, dotColor, bodyPattern, cornerEyePattern, cornerEyeDotPattern, level, scale, margin, templateId, customTemplate, customProps, }: QRCodeProps) => import("react").JSX.Element>;
|
|
9
|
+
export declare const QRCode: import("react").MemoExoticComponent<({ value, fgColor, hideLogo, logo, logoOptions, bgColor, eyeColor, dotColor, bodyPattern, cornerEyePattern, cornerEyeDotPattern, level, size, scale, margin, style, templateId, customTemplate, customProps, frame, art, eyeColors, moduleScale, autoLevel, shape, frameLabelMarkers, }: QRCodeProps) => import("react").JSX.Element>;
|
|
8
10
|
export {};
|
|
9
11
|
//# sourceMappingURL=qr-code.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qr-code.d.ts","sourceRoot":"","sources":["../../src/qr-code.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"qr-code.d.ts","sourceRoot":"","sources":["../../src/qr-code.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKrD,UAAU,WAAY,SAAQ,OAAO;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,MAAM,+TA4Bd,WAAW,iCAwFf,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/noMagicNumbers: outline geometry */
|
|
2
|
+
import { type QRSilhouette } from "../types/qr";
|
|
3
|
+
type Point = [number, number];
|
|
4
|
+
/** A line to its point, a quadratic (control, end) or a cubic (c1, c2, end). */
|
|
5
|
+
type Segment = Point[];
|
|
6
|
+
interface Ring {
|
|
7
|
+
start: Point;
|
|
8
|
+
segments: Segment[];
|
|
9
|
+
}
|
|
10
|
+
export interface Outline {
|
|
11
|
+
/** Closed rings in artwork units (0 to 1), filled even-odd */
|
|
12
|
+
rings: Ring[];
|
|
13
|
+
/** The rings flattened into polygons, for inside tests */
|
|
14
|
+
polygons: Point[][];
|
|
15
|
+
/** Half side of the largest square centered on (0.5, 0.5) inside it */
|
|
16
|
+
half: number;
|
|
17
|
+
}
|
|
18
|
+
/** True when (x, y) is inside the polygons (even-odd). */
|
|
19
|
+
export declare function insidePolygons(polygons: Point[][], x: number, y: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Inside tests at many points, caching each row's crossings (decoration
|
|
22
|
+
* samples a few rows per module row).
|
|
23
|
+
*/
|
|
24
|
+
export declare function insideTester(polygons: Point[][]): (x: number, y: number) => boolean;
|
|
25
|
+
/** SVG path data for an outline drawn `size` px across. */
|
|
26
|
+
export declare function outlinePath(outline: Outline, size: number): string;
|
|
27
|
+
/** The heart, placed on the artwork. */
|
|
28
|
+
export declare function getHeartOutline(): Outline;
|
|
29
|
+
/** Why a silhouette can't hold a code, or null when it can. */
|
|
30
|
+
export type SilhouetteProblem = "invalid" | "empty" | "thin";
|
|
31
|
+
/**
|
|
32
|
+
* The silhouette's outline on the artwork, or why it can't hold a code:
|
|
33
|
+
* "invalid" (not a well-formed grid), "empty" (no cells inside) or "thin"
|
|
34
|
+
* (the symbol would take less than QR_SILHOUETTE_MIN_SHARE of the width).
|
|
35
|
+
*/
|
|
36
|
+
export declare function getSilhouetteOutline(silhouette: QRSilhouette): {
|
|
37
|
+
outline: Outline | null;
|
|
38
|
+
problem: SilhouetteProblem | null;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=qr-outline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr-outline.d.ts","sourceRoot":"","sources":["../../src/qr-outline.ts"],"names":[],"mappings":"AAAA,mEAAmE;AASnE,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAGrB,KAAK,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9B,gFAAgF;AAChF,KAAK,OAAO,GAAG,KAAK,EAAE,CAAC;AAEvB,UAAU,IAAI;IACZ,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACtB,8DAA8D;IAC9D,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,0DAA0D;IAC1D,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC;IACpB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;CACd;AAkED,0DAA0D;AAC1D,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,KAAK,EAAE,EAAE,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,IAEtC,GAAG,MAAM,EAAE,GAAG,MAAM,aAQ7B;AA8HD,2DAA2D;AAC3D,wBA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