qrdx 0.0.61 → 0.0.62
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 +2 -1
- package/dist/angular.js +7 -2
- package/dist/angular.js.map +1 -1
- package/dist/angular.mjs +7 -2
- 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/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 +2 -1
- package/dist/src/element.d.ts +2 -0
- package/dist/src/element.d.ts.map +1 -1
- package/dist/src/helpers.d.ts +2 -2
- package/dist/src/helpers.d.ts.map +1 -1
- package/dist/src/logo-budget.d.ts +3 -1
- package/dist/src/logo-budget.d.ts.map +1 -1
- package/dist/src/looks.d.ts +2 -2
- package/dist/src/looks.d.ts.map +1 -1
- 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 +1 -1
- package/dist/src/qr-code-props.d.ts.map +1 -1
- package/dist/src/scan-score.d.ts.map +1 -1
- package/dist/src/symbol.d.ts +13 -0
- package/dist/src/symbol.d.ts.map +1 -0
- package/dist/src/utils/print-shared.d.ts.map +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/vue.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/qr.d.ts +2 -0
- package/dist/types/qr.d.ts.map +1 -1
- package/dist/vanilla.browser.mjs +16 -16
- 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 +1 -1
- package/src/angular.ts +2 -0
- package/src/element.ts +3 -0
- package/src/helpers.ts +27 -10
- package/src/logo-budget.ts +9 -8
- package/src/looks.ts +17 -14
- package/src/plain.tsx +5 -7
- package/src/print.ts +3 -6
- package/src/qr-code-canvas.tsx +5 -7
- package/src/qr-code-props.ts +4 -0
- package/src/scan-score.ts +5 -4
- package/src/symbol.ts +27 -0
- package/src/utils/print-shared.ts +5 -9
- package/src/utils.tsx +9 -9
- package/src/vue.ts +1 -0
- package/types/qr.ts +6 -0
package/dist/vue.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var vue=require('vue'),core_js=require('./core.js');var
|
|
1
|
+
'use strict';var vue=require('vue'),core_js=require('./core.js');var l={type:Boolean,default:void 0},C={value:{type:String,required:true},size:Number,level:null,bgColor:null,fgColor:null,eyeColor:null,dotColor:null,bodyPattern:null,cornerEyePattern:null,cornerEyeDotPattern:null,margin:Number,imageSettings:null,isOGContext:l,templateId:null,customTemplate:null,customProps:null,frame:null,art:null,eyeColors:null,moduleScale:Number,autoLevel:l,exactLevel:l,shape:null,eyeShapes:null,eyeGradient:null,bgRadius:Number,backdrop:null,halo:null,shadow:null,frameLabelMarkers:l,partMarkers:l},G={...C,logo:String,logoOptions:null,hideLogo:l,scale:Number},b=t=>/^on[^a-z]/.test(t);function y(t,e){let o=core_js.toHyperscript(core_js.createQRCodeTree({...t,...e}),(s,a,c,i)=>vue.h(s,i===null?a:{...a,key:i},c)),n=null;for(let s of Object.keys(e))b(s)&&(n??={},n[s]=e[s]);let[r]=o;return n&&vue.isVNode(r)&&(o[0]=vue.h(r.type,{...r.props,...n},r.children)),o.length===1?o[0]:o}var O=vue.defineComponent((t,{attrs:e})=>()=>y(t,e),{name:"QRCodeSVG",inheritAttrs:false,props:C}),N=vue.defineComponent((t,{attrs:e})=>{let o=vue.computed(()=>core_js.resolveQRCodeProps(t));return ()=>y(o.value,e)},{name:"QRCode",inheritAttrs:false,props:G}),d=(t,e)=>{let o=e??t.size??core_js.DEFAULT_SIZE;return {width:o,height:o}};function w(t){let e=vue.computed(()=>core_js.resolveQRCodeProps(vue.toValue(t))),o=vue.computed(()=>core_js.toSVGString(e.value));return {options:e,svg:o,toDataURL(n="png",r={}){return core_js.getQRCodeDataUrl(e.value,n,d(e.value,r.size),{quality:r.quality})},download(n={}){return core_js.downloadQRCode(e.value,{format:n.format??"png",size:d(e.value,n.size),filename:n.filename,quality:n.quality})}}}exports.QRCode=N;exports.QRCodeSVG=O;exports.useQRCode=w;Object.keys(core_js).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core_js[k]}})});//# sourceMappingURL=vue.js.map
|
|
2
2
|
//# sourceMappingURL=vue.js.map
|
package/dist/vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vue.ts"],"names":["flag","svgProps","codeProps","isListener","key","draw","options","attrs","nodes","toHyperscript","createQRCodeTree","type","attributes","children","h","listeners","root","isVNode","QRCodeSVG","defineComponent","props","QRCode","computed","resolveQRCodeProps","exportSize","size","side","DEFAULT_SIZE","useQRCode","toValue","svg","toSVGString","format","exportOptions","getQRCodeDataUrl","downloadOptions","downloadQRCode"],"mappings":"iEA0DA,IAAMA,EAAO,CAAE,IAAA,CAAM,QAAS,OAAA,CAAS,MAAU,EAE3CC,CAAAA,CAAW,CACf,MAAO,CAAE,IAAA,CAAM,OAAQ,QAAA,CAAU,IAAK,CAAA,CACtC,IAAA,CAAM,OACN,KAAA,CAAO,IAAA,CACP,QAAS,IAAA,CACT,OAAA,CAAS,KACT,QAAA,CAAU,IAAA,CACV,SAAU,IAAA,CACV,WAAA,CAAa,KACb,gBAAA,CAAkB,IAAA,CAClB,oBAAqB,IAAA,CACrB,MAAA,CAAQ,OACR,aAAA,CAAe,IAAA,CACf,YAAaD,CAAAA,CACb,UAAA,CAAY,KACZ,cAAA,CAAgB,IAAA,CAChB,YAAa,IAAA,CACb,KAAA,CAAO,KACP,GAAA,CAAK,IAAA,CACL,UAAW,IAAA,CACX,WAAA,CAAa,OACb,SAAA,CAAWA,CAAAA,CACX,
|
|
1
|
+
{"version":3,"sources":["../src/vue.ts"],"names":["flag","svgProps","codeProps","isListener","key","draw","options","attrs","nodes","toHyperscript","createQRCodeTree","type","attributes","children","h","listeners","root","isVNode","QRCodeSVG","defineComponent","props","QRCode","computed","resolveQRCodeProps","exportSize","size","side","DEFAULT_SIZE","useQRCode","toValue","svg","toSVGString","format","exportOptions","getQRCodeDataUrl","downloadOptions","downloadQRCode"],"mappings":"iEA0DA,IAAMA,EAAO,CAAE,IAAA,CAAM,QAAS,OAAA,CAAS,MAAU,EAE3CC,CAAAA,CAAW,CACf,MAAO,CAAE,IAAA,CAAM,OAAQ,QAAA,CAAU,IAAK,CAAA,CACtC,IAAA,CAAM,OACN,KAAA,CAAO,IAAA,CACP,QAAS,IAAA,CACT,OAAA,CAAS,KACT,QAAA,CAAU,IAAA,CACV,SAAU,IAAA,CACV,WAAA,CAAa,KACb,gBAAA,CAAkB,IAAA,CAClB,oBAAqB,IAAA,CACrB,MAAA,CAAQ,OACR,aAAA,CAAe,IAAA,CACf,YAAaD,CAAAA,CACb,UAAA,CAAY,KACZ,cAAA,CAAgB,IAAA,CAChB,YAAa,IAAA,CACb,KAAA,CAAO,KACP,GAAA,CAAK,IA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CAASA,CAAAA,CAAc,OAAQ,CACnC,CACF,EACA,QAAA,CAASE,CAAAA,CAAkB,EAAC,CAAG,CAC7B,OAAOC,sBAAAA,CAAe9B,CAAAA,CAAQ,MAAO,CACnC,MAAA,CAAQ6B,EAAgB,MAAA,EAAU,KAAA,CAClC,KAAMX,CAAAA,CAAWlB,CAAAA,CAAQ,MAAO6B,CAAAA,CAAgB,IAAI,EACpD,QAAA,CAAUA,CAAAA,CAAgB,SAC1B,OAAA,CAASA,CAAAA,CAAgB,OAC3B,CAAC,CACH,CACF,CACF","file":"vue.js"}
|
package/dist/vue.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {defineComponent,computed,h,isVNode,toValue}from'vue';import {resolveQRCodeProps,toHyperscript,createQRCodeTree,toSVGString,downloadQRCode,getQRCodeDataUrl,DEFAULT_SIZE}from'./core.mjs';export*from'./core.mjs';var
|
|
1
|
+
import {defineComponent,computed,h,isVNode,toValue}from'vue';import {resolveQRCodeProps,toHyperscript,createQRCodeTree,toSVGString,downloadQRCode,getQRCodeDataUrl,DEFAULT_SIZE}from'./core.mjs';export*from'./core.mjs';var l={type:Boolean,default:void 0},C={value:{type:String,required:true},size:Number,level:null,bgColor:null,fgColor:null,eyeColor:null,dotColor:null,bodyPattern:null,cornerEyePattern:null,cornerEyeDotPattern:null,margin:Number,imageSettings:null,isOGContext:l,templateId:null,customTemplate:null,customProps:null,frame:null,art:null,eyeColors:null,moduleScale:Number,autoLevel:l,exactLevel:l,shape:null,eyeShapes:null,eyeGradient:null,bgRadius:Number,backdrop:null,halo:null,shadow:null,frameLabelMarkers:l,partMarkers:l},G={...C,logo:String,logoOptions:null,hideLogo:l,scale:Number},b=t=>/^on[^a-z]/.test(t);function y(t,e){let o=toHyperscript(createQRCodeTree({...t,...e}),(s,a,c,i)=>h(s,i===null?a:{...a,key:i},c)),n=null;for(let s of Object.keys(e))b(s)&&(n??={},n[s]=e[s]);let[r]=o;return n&&isVNode(r)&&(o[0]=h(r.type,{...r.props,...n},r.children)),o.length===1?o[0]:o}var O=defineComponent((t,{attrs:e})=>()=>y(t,e),{name:"QRCodeSVG",inheritAttrs:false,props:C}),N=defineComponent((t,{attrs:e})=>{let o=computed(()=>resolveQRCodeProps(t));return ()=>y(o.value,e)},{name:"QRCode",inheritAttrs:false,props:G}),d=(t,e)=>{let o=e??t.size??DEFAULT_SIZE;return {width:o,height:o}};function w(t){let e=computed(()=>resolveQRCodeProps(toValue(t))),o=computed(()=>toSVGString(e.value));return {options:e,svg:o,toDataURL(n="png",r={}){return getQRCodeDataUrl(e.value,n,d(e.value,r.size),{quality:r.quality})},download(n={}){return downloadQRCode(e.value,{format:n.format??"png",size:d(e.value,n.size),filename:n.filename,quality:n.quality})}}}export{N as QRCode,O as QRCodeSVG,w as useQRCode};//# sourceMappingURL=vue.mjs.map
|
|
2
2
|
//# sourceMappingURL=vue.mjs.map
|
package/dist/vue.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vue.ts"],"names":["flag","svgProps","codeProps","isListener","key","draw","options","attrs","nodes","toHyperscript","createQRCodeTree","type","attributes","children","h","listeners","root","isVNode","QRCodeSVG","defineComponent","props","QRCode","computed","resolveQRCodeProps","exportSize","size","side","DEFAULT_SIZE","useQRCode","toValue","svg","toSVGString","format","exportOptions","getQRCodeDataUrl","downloadOptions","downloadQRCode"],"mappings":"yNA0DA,IAAMA,EAAO,CAAE,IAAA,CAAM,QAAS,OAAA,CAAS,MAAU,EAE3CC,CAAAA,CAAW,CACf,MAAO,CAAE,IAAA,CAAM,OAAQ,QAAA,CAAU,IAAK,CAAA,CACtC,IAAA,CAAM,OACN,KAAA,CAAO,IAAA,CACP,QAAS,IAAA,CACT,OAAA,CAAS,KACT,QAAA,CAAU,IAAA,CACV,SAAU,IAAA,CACV,WAAA,CAAa,KACb,gBAAA,CAAkB,IAAA,CAClB,oBAAqB,IAAA,CACrB,MAAA,CAAQ,OACR,aAAA,CAAe,IAAA,CACf,YAAaD,CAAAA,CACb,UAAA,CAAY,KACZ,cAAA,CAAgB,IAAA,CAChB,YAAa,IAAA,CACb,KAAA,CAAO,KACP,GAAA,CAAK,IAAA,CACL,UAAW,IAAA,CACX,WAAA,CAAa,OACb,SAAA,CAAWA,CAAAA,CACX,
|
|
1
|
+
{"version":3,"sources":["../src/vue.ts"],"names":["flag","svgProps","codeProps","isListener","key","draw","options","attrs","nodes","toHyperscript","createQRCodeTree","type","attributes","children","h","listeners","root","isVNode","QRCodeSVG","defineComponent","props","QRCode","computed","resolveQRCodeProps","exportSize","size","side","DEFAULT_SIZE","useQRCode","toValue","svg","toSVGString","format","exportOptions","getQRCodeDataUrl","downloadOptions","downloadQRCode"],"mappings":"yNA0DA,IAAMA,EAAO,CAAE,IAAA,CAAM,QAAS,OAAA,CAAS,MAAU,EAE3CC,CAAAA,CAAW,CACf,MAAO,CAAE,IAAA,CAAM,OAAQ,QAAA,CAAU,IAAK,CAAA,CACtC,IAAA,CAAM,OACN,KAAA,CAAO,IAAA,CACP,QAAS,IAAA,CACT,OAAA,CAAS,KACT,QAAA,CAAU,IAAA,CACV,SAAU,IAAA,CACV,WAAA,CAAa,KACb,gBAAA,CAAkB,IAAA,CAClB,oBAAqB,IAAA,CACrB,MAAA,CAAQ,OACR,aAAA,CAAe,IAAA,CACf,YAAaD,CAAAA,CACb,UAAA,CAAY,KACZ,cAAA,CAAgB,IAAA,CAChB,YAAa,IAAA,CACb,KAAA,CAAO,KACP,GAAA,CAAK,IAAA,CACL,UAAW,IAAA,CACX,WAAA,CAAa,OACb,SAAA,CAAWA,CAAAA,CACX,WAAYA,CAAAA,CACZ,KAAA,CAAO,KACP,SAAA,CAAW,IAAA,CACX,WAAA,CAAa,IAAA,CACb,SAAU,MAAA,CACV,QAAA,CAAU,KACV,IAAA,CAAM,IAAA,CACN,OAAQ,IAAA,CACR,iBAAA,CAAmBA,EACnB,WAAA,CAAaA,CACf,EAEME,CAAAA,CAAY,CAChB,GAAGD,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,CAAAA,CAAgB,OAC3B,CAAC,CACH,CACF,CACF","file":"vue.mjs"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qrdx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.62",
|
|
4
4
|
"description": "Customizable QR code generator for React and plain JavaScript: SVG and canvas rendering, dot and eye patterns, gradients, logos, frames, Logo QR and Image QR art, PNG/JPG/WebP/SVG/PDF/EPS export, a scan score and QR scanning.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"qr-code",
|
package/src/angular.ts
CHANGED
|
@@ -106,6 +106,7 @@ export class QRCode implements QRCodeInputs {
|
|
|
106
106
|
readonly logoOptions: Prop<"logoOptions"> = input();
|
|
107
107
|
readonly hideLogo: Prop<"hideLogo"> = input();
|
|
108
108
|
readonly autoLevel: Prop<"autoLevel"> = input();
|
|
109
|
+
readonly exactLevel: Prop<"exactLevel"> = input();
|
|
109
110
|
readonly scale: Prop<"scale"> = input();
|
|
110
111
|
readonly templateId: Prop<"templateId"> = input();
|
|
111
112
|
readonly customTemplate: Prop<"customTemplate"> = input();
|
|
@@ -148,6 +149,7 @@ export class QRCode implements QRCodeInputs {
|
|
|
148
149
|
logoOptions: this.logoOptions(),
|
|
149
150
|
hideLogo: this.hideLogo(),
|
|
150
151
|
autoLevel: this.autoLevel(),
|
|
152
|
+
exactLevel: this.exactLevel(),
|
|
151
153
|
scale: this.scale(),
|
|
152
154
|
templateId: this.templateId(),
|
|
153
155
|
customTemplate: this.customTemplate(),
|
package/src/element.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface QRdxCodeProperties {
|
|
|
36
36
|
templateId?: QRProps["templateId"];
|
|
37
37
|
moduleScale?: QRProps["moduleScale"];
|
|
38
38
|
autoLevel?: QRProps["autoLevel"];
|
|
39
|
+
exactLevel?: QRProps["exactLevel"];
|
|
39
40
|
shape?: QRProps["shape"];
|
|
40
41
|
eyeGradient?: QRProps["eyeGradient"];
|
|
41
42
|
bgRadius?: QRProps["bgRadius"];
|
|
@@ -113,6 +114,7 @@ const ATTRIBUTES: Record<string, [OptionKey, AttributeKind]> = {
|
|
|
113
114
|
"template-id": ["templateId", "string"],
|
|
114
115
|
"module-scale": ["moduleScale", "number"],
|
|
115
116
|
"auto-level": ["autoLevel", "boolean"],
|
|
117
|
+
"exact-level": ["exactLevel", "boolean"],
|
|
116
118
|
shape: ["shape", "string"],
|
|
117
119
|
"eye-gradient": ["eyeGradient", "string"],
|
|
118
120
|
"bg-radius": ["bgRadius", "number"],
|
|
@@ -239,6 +241,7 @@ export class QRdxCodeElement extends BaseElement {
|
|
|
239
241
|
declare templateId: QRdxCodeProperties["templateId"];
|
|
240
242
|
declare moduleScale: QRdxCodeProperties["moduleScale"];
|
|
241
243
|
declare autoLevel: QRdxCodeProperties["autoLevel"];
|
|
244
|
+
declare exactLevel: QRdxCodeProperties["exactLevel"];
|
|
242
245
|
declare shape: QRdxCodeProperties["shape"];
|
|
243
246
|
declare frame: QRdxCodeProperties["frame"];
|
|
244
247
|
declare imageSettings: QRdxCodeProperties["imageSettings"];
|
package/src/helpers.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ErrorLevel, ImageSettings, LogoOptions, QRProps } from "../types";
|
|
2
2
|
import { LOGO_SIZE_DEFAULT, LOGO_SIZE_MAX } from "../types/constants";
|
|
3
|
-
import
|
|
4
|
-
import { DEFAULT_LEVEL, DEFAULT_MARGIN, ERROR_LEVEL_MAP } from "./constants";
|
|
3
|
+
import { DEFAULT_LEVEL, DEFAULT_MARGIN } from "./constants";
|
|
5
4
|
import { fitLogoWidth } from "./logo-budget";
|
|
6
5
|
import { getLayoutMargin } from "./qr-shape";
|
|
6
|
+
import { encodeSymbol } from "./symbol";
|
|
7
7
|
import { resolveErrorLevel } from "./utils";
|
|
8
8
|
|
|
9
9
|
interface QRDataProps extends QRProps {
|
|
@@ -21,11 +21,12 @@ interface QRDataResult extends QRProps {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/** Modules across the symbol (no margin) for `value` at `level`. */
|
|
24
|
-
function symbolModules(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
function symbolModules(
|
|
25
|
+
value: string,
|
|
26
|
+
level: QRProps["level"],
|
|
27
|
+
exactLevel: boolean | undefined
|
|
28
|
+
): number {
|
|
29
|
+
return encodeSymbol(value, level ?? DEFAULT_LEVEL, exactLevel).size;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -42,6 +43,7 @@ function logoImageSettings(
|
|
|
42
43
|
margin: number;
|
|
43
44
|
level?: QRProps["level"];
|
|
44
45
|
shape?: QRProps["shape"];
|
|
46
|
+
exactLevel?: boolean;
|
|
45
47
|
},
|
|
46
48
|
width = code.size * (options?.size ?? LOGO_SIZE_DEFAULT)
|
|
47
49
|
): ImageSettings {
|
|
@@ -58,7 +60,7 @@ function logoImageSettings(
|
|
|
58
60
|
if (!(options?.padding || positioned)) {
|
|
59
61
|
return settings;
|
|
60
62
|
}
|
|
61
|
-
const modules = symbolModules(code.value, code.level);
|
|
63
|
+
const modules = symbolModules(code.value, code.level, code.exactLevel);
|
|
62
64
|
// A circle code draws its symbol further in (see qr-shape.ts)
|
|
63
65
|
const margin = getLayoutMargin(modules, code.margin, code.shape);
|
|
64
66
|
const modulePx = code.size / (modules + 2 * margin);
|
|
@@ -93,6 +95,7 @@ function capLogo(
|
|
|
93
95
|
margin: number;
|
|
94
96
|
level?: QRProps["level"];
|
|
95
97
|
shape?: QRProps["shape"];
|
|
98
|
+
exactLevel?: boolean;
|
|
96
99
|
},
|
|
97
100
|
autoLevel: boolean | undefined
|
|
98
101
|
): ImageSettings | undefined {
|
|
@@ -139,15 +142,26 @@ export function getLogoSizeLimit({
|
|
|
139
142
|
margin,
|
|
140
143
|
shape,
|
|
141
144
|
autoLevel,
|
|
145
|
+
exactLevel,
|
|
142
146
|
logoOptions,
|
|
143
|
-
}: Pick<
|
|
147
|
+
}: Pick<
|
|
148
|
+
QRProps,
|
|
149
|
+
"value" | "level" | "margin" | "shape" | "autoLevel" | "exactLevel"
|
|
150
|
+
> & {
|
|
144
151
|
logoOptions?: LogoOptions;
|
|
145
152
|
}): number {
|
|
146
153
|
const size = 1024;
|
|
147
154
|
const settings = capLogo(
|
|
148
155
|
"data:,",
|
|
149
156
|
{ ...logoOptions, size: LOGO_SIZE_MAX },
|
|
150
|
-
{
|
|
157
|
+
{
|
|
158
|
+
value: `${value}`,
|
|
159
|
+
size,
|
|
160
|
+
margin: margin ?? DEFAULT_MARGIN,
|
|
161
|
+
level,
|
|
162
|
+
shape,
|
|
163
|
+
exactLevel,
|
|
164
|
+
},
|
|
151
165
|
autoLevel
|
|
152
166
|
);
|
|
153
167
|
return settings ? settings.width / size : 0;
|
|
@@ -173,6 +187,7 @@ export function getQRData({
|
|
|
173
187
|
eyeColors,
|
|
174
188
|
moduleScale,
|
|
175
189
|
autoLevel,
|
|
190
|
+
exactLevel,
|
|
176
191
|
shape,
|
|
177
192
|
eyeShapes,
|
|
178
193
|
eyeGradient,
|
|
@@ -187,6 +202,7 @@ export function getQRData({
|
|
|
187
202
|
margin: margin ?? DEFAULT_MARGIN,
|
|
188
203
|
level,
|
|
189
204
|
shape,
|
|
205
|
+
exactLevel,
|
|
190
206
|
};
|
|
191
207
|
// No default logo: only render (and excavate for) one the caller passes.
|
|
192
208
|
const imageSettings =
|
|
@@ -208,6 +224,7 @@ export function getQRData({
|
|
|
208
224
|
...(eyeColors && { eyeColors }),
|
|
209
225
|
...(moduleScale !== undefined && { moduleScale }),
|
|
210
226
|
...(autoLevel && { autoLevel }),
|
|
227
|
+
...(exactLevel && { exactLevel }),
|
|
211
228
|
...(shape && shape !== "square" && { shape }),
|
|
212
229
|
...(eyeShapes && { eyeShapes }),
|
|
213
230
|
...(eyeGradient && eyeGradient !== "corner" && { eyeGradient }),
|
package/src/logo-budget.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
// The budget is the one the Logo QR badge uses (art.tsx): 60% of each
|
|
9
9
|
// block's repair capacity, which leaves room for print and camera errors.
|
|
10
10
|
import type { ErrorLevel, ImageSettings, QRCodeShape } from "../types";
|
|
11
|
-
import qrcodegen from "./codegen";
|
|
12
11
|
import { damagedCodewords, getCodewordMap } from "./codeword-map";
|
|
13
|
-
import { DEFAULT_IMG_SCALE, DEFAULT_LEVEL
|
|
12
|
+
import { DEFAULT_IMG_SCALE, DEFAULT_LEVEL } from "./constants";
|
|
14
13
|
import { getLayoutMargin } from "./qr-shape";
|
|
14
|
+
import { encodeSymbol } from "./symbol";
|
|
15
15
|
import { getImageSettings, resolveErrorLevel } from "./utils";
|
|
16
16
|
|
|
17
17
|
/** Share of each block's repair capacity a logo may use (as the badge). */
|
|
@@ -26,7 +26,7 @@ export interface LogoBlockDamage {
|
|
|
26
26
|
correctable: number;
|
|
27
27
|
/** Most the logo may spoil per block: correctable × LOGO_EC_SAFETY */
|
|
28
28
|
budget: number;
|
|
29
|
-
/** The level the symbol is really drawn at (qrcodegen may boost it) */
|
|
29
|
+
/** The level the symbol is really drawn at (qrcodegen may boost it, unless exactLevel) */
|
|
30
30
|
level: ErrorLevel;
|
|
31
31
|
version: number;
|
|
32
32
|
}
|
|
@@ -38,6 +38,8 @@ export interface LogoCode {
|
|
|
38
38
|
margin: number;
|
|
39
39
|
level: ErrorLevel;
|
|
40
40
|
shape?: QRCodeShape;
|
|
41
|
+
/** Encoded at exactly `level`, not boosted (see QRProps.exactLevel) */
|
|
42
|
+
exactLevel?: boolean;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
interface BudgetContext {
|
|
@@ -51,11 +53,9 @@ interface BudgetContext {
|
|
|
51
53
|
|
|
52
54
|
/** The symbol and its codeword map, encoded once per code and level. */
|
|
53
55
|
function budgetContext(code: LogoCode): BudgetContext {
|
|
54
|
-
const qr =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
// qrcodegen raises the level when the data fits anyway: count with that
|
|
56
|
+
const qr = encodeSymbol(code.value, code.level, code.exactLevel);
|
|
57
|
+
// qrcodegen raises the level when the data fits anyway (unless
|
|
58
|
+
// exactLevel): count with the level the symbol really has
|
|
59
59
|
const level = LEVELS[qr.errorCorrectionLevel.ordinal] ?? code.level;
|
|
60
60
|
return {
|
|
61
61
|
code,
|
|
@@ -205,6 +205,7 @@ export function capImageSettings(
|
|
|
205
205
|
size: code.size,
|
|
206
206
|
margin: code.margin,
|
|
207
207
|
shape: code.shape,
|
|
208
|
+
exactLevel: code.exactLevel,
|
|
208
209
|
};
|
|
209
210
|
const drawnAt = (settings: ImageSettings) =>
|
|
210
211
|
resolveErrorLevel({ ...code, level: requested, imageSettings: settings });
|
package/src/looks.ts
CHANGED
|
@@ -32,16 +32,11 @@ import {
|
|
|
32
32
|
WITHDRAWN_CORNER_EYE_PATTERNS,
|
|
33
33
|
withdrawnFallback,
|
|
34
34
|
} from "../types/constants";
|
|
35
|
-
import
|
|
36
|
-
import {
|
|
37
|
-
DEFAULT_BGCOLOR,
|
|
38
|
-
DEFAULT_MARGIN,
|
|
39
|
-
DEFAULT_SIZE,
|
|
40
|
-
ERROR_LEVEL_MAP,
|
|
41
|
-
} from "./constants";
|
|
35
|
+
import { DEFAULT_BGCOLOR, DEFAULT_MARGIN, DEFAULT_SIZE } from "./constants";
|
|
42
36
|
import { capImageSettings } from "./logo-budget";
|
|
43
37
|
import { isShapedCode } from "./qr-shape";
|
|
44
38
|
import { getStylePairRisk, type StylePairRisk } from "./scan-risk";
|
|
39
|
+
import { encodeSymbol } from "./symbol";
|
|
45
40
|
import { resolveErrorLevel } from "./utils";
|
|
46
41
|
import { oklchToRgb, rgbToOklch } from "./utils/oklab";
|
|
47
42
|
import { parseColor, type RGBAColor } from "./utils/parse-color";
|
|
@@ -175,7 +170,7 @@ export function clampBgRadius(
|
|
|
175
170
|
* The largest `bgRadius` (share of the code's width) this code keeps its
|
|
176
171
|
* quiet zone with, for an editor's slider: 0 when the code has no margin
|
|
177
172
|
* or is shaped. The level is the one the renderer draws at: given the
|
|
178
|
-
* logo (`imageSettings`) and `
|
|
173
|
+
* logo (`imageSettings`), `autoLevel` and `exactLevel`, the logo is held to its budget
|
|
179
174
|
* first and the level resolved with it after, as createQRCodeTree does.
|
|
180
175
|
*/
|
|
181
176
|
export function getBgRadiusLimit(
|
|
@@ -187,14 +182,24 @@ export function getBgRadiusLimit(
|
|
|
187
182
|
| "shape"
|
|
188
183
|
| "size"
|
|
189
184
|
| "autoLevel"
|
|
185
|
+
| "exactLevel"
|
|
190
186
|
| "imageSettings"
|
|
191
187
|
> & { isOGContext?: boolean }
|
|
192
188
|
): number {
|
|
193
|
-
const { value, level, shape, autoLevel, isOGContext } = props;
|
|
189
|
+
const { value, level, shape, autoLevel, exactLevel, isOGContext } = props;
|
|
194
190
|
const size = props.size ?? DEFAULT_SIZE;
|
|
195
191
|
const margin = props.margin ?? DEFAULT_MARGIN;
|
|
196
192
|
const imageSettings = capImageSettings(
|
|
197
|
-
{
|
|
193
|
+
{
|
|
194
|
+
value: `${value}`,
|
|
195
|
+
size,
|
|
196
|
+
margin,
|
|
197
|
+
level,
|
|
198
|
+
shape,
|
|
199
|
+
autoLevel,
|
|
200
|
+
exactLevel,
|
|
201
|
+
isOGContext,
|
|
202
|
+
},
|
|
198
203
|
props.imageSettings
|
|
199
204
|
);
|
|
200
205
|
const drawn = resolveErrorLevel({
|
|
@@ -205,12 +210,10 @@ export function getBgRadiusLimit(
|
|
|
205
210
|
imageSettings,
|
|
206
211
|
isOGContext,
|
|
207
212
|
autoLevel,
|
|
213
|
+
exactLevel,
|
|
208
214
|
shape,
|
|
209
215
|
});
|
|
210
|
-
const modules =
|
|
211
|
-
`${value}`,
|
|
212
|
-
ERROR_LEVEL_MAP[drawn]
|
|
213
|
-
).size;
|
|
216
|
+
const modules = encodeSymbol(`${value}`, drawn, exactLevel).size;
|
|
214
217
|
return clampBgRadius(BG_RADIUS_MAX, modules, margin, shape);
|
|
215
218
|
}
|
|
216
219
|
|
package/src/plain.tsx
CHANGED
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
// background rect, an optional logo and frame, and no styling. Split in two
|
|
4
4
|
// so the React entry can draw the same tree with React's elements.
|
|
5
5
|
import type { ImageSettings, QRSVGOptions } from "../types";
|
|
6
|
-
import qrcodegen from "./codegen";
|
|
7
6
|
import {
|
|
8
7
|
DEFAULT_BGCOLOR,
|
|
9
8
|
DEFAULT_FGCOLOR,
|
|
10
9
|
DEFAULT_LEVEL,
|
|
11
10
|
DEFAULT_MARGIN,
|
|
12
11
|
DEFAULT_SIZE,
|
|
13
|
-
ERROR_LEVEL_MAP,
|
|
14
12
|
} from "./constants";
|
|
15
13
|
import { isFrameActive, wrapWithFrame } from "./frame";
|
|
16
14
|
import type { QRNode } from "./jsx/runtime";
|
|
17
15
|
import { renderLogo } from "./logo";
|
|
18
16
|
import { capImageSettings } from "./logo-budget";
|
|
17
|
+
import { encodeSymbol } from "./symbol";
|
|
19
18
|
import {
|
|
20
19
|
excavateModules,
|
|
21
20
|
generatePath,
|
|
@@ -76,11 +75,12 @@ export async function preparePlainQRCode(
|
|
|
76
75
|
frameLabelMarkers: _frameLabelMarkers,
|
|
77
76
|
partMarkers: _partMarkers,
|
|
78
77
|
autoLevel,
|
|
78
|
+
exactLevel,
|
|
79
79
|
...otherProps
|
|
80
80
|
} = props;
|
|
81
81
|
// A logo no bigger than the code can repair (logo-budget.ts)
|
|
82
82
|
const imageSettings = capImageSettings(
|
|
83
|
-
{ value, size, margin, level, autoLevel },
|
|
83
|
+
{ value, size, margin, level, autoLevel, exactLevel },
|
|
84
84
|
requestedImageSettings
|
|
85
85
|
);
|
|
86
86
|
const effectiveLevel = resolveErrorLevel({
|
|
@@ -90,12 +90,10 @@ export async function preparePlainQRCode(
|
|
|
90
90
|
margin,
|
|
91
91
|
imageSettings,
|
|
92
92
|
autoLevel,
|
|
93
|
+
exactLevel,
|
|
93
94
|
});
|
|
94
95
|
|
|
95
|
-
let cells =
|
|
96
|
-
value,
|
|
97
|
-
ERROR_LEVEL_MAP[effectiveLevel]
|
|
98
|
-
).getModules();
|
|
96
|
+
let cells = encodeSymbol(value, effectiveLevel, exactLevel).getModules();
|
|
99
97
|
|
|
100
98
|
const numCells = cells.length + margin * 2;
|
|
101
99
|
const calculatedImageSettings = getImageSettings(
|
package/src/print.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** biome-ignore-all lint/style/noMagicNumbers: print measurements */
|
|
2
2
|
import type { jsPDF as JsPDF, ShadingPattern } from "jspdf";
|
|
3
3
|
import type { QRProps } from "../types";
|
|
4
|
-
import
|
|
5
|
-
import { DEFAULT_MARGIN, ERROR_LEVEL_MAP } from "./constants";
|
|
4
|
+
import { DEFAULT_MARGIN } from "./constants";
|
|
6
5
|
import { downloadFile } from "./download";
|
|
7
6
|
import { getFrameLayout, isFrameActive } from "./frame";
|
|
8
7
|
import { getLayoutMargin } from "./qr-shape";
|
|
8
|
+
import { encodeSymbol } from "./symbol";
|
|
9
9
|
import { resolveErrorLevel } from "./utils";
|
|
10
10
|
import { COORD_DECIMALS, fmt } from "./utils/fmt";
|
|
11
11
|
import { type RGBAColor, rgbToCmyk } from "./utils/parse-color";
|
|
@@ -100,10 +100,7 @@ function toMillimetres(value: number, unit: PrintUnit = "mm"): number {
|
|
|
100
100
|
/** Modules across the code for these props, margin included. */
|
|
101
101
|
export function getQRModuleCount(props: QRProps): number {
|
|
102
102
|
const level = resolveErrorLevel(props);
|
|
103
|
-
const symbol =
|
|
104
|
-
props.value,
|
|
105
|
-
ERROR_LEVEL_MAP[level]
|
|
106
|
-
).size;
|
|
103
|
+
const symbol = encodeSymbol(props.value, level, props.exactLevel).size;
|
|
107
104
|
// A circle code is drawn further in, inside its disc
|
|
108
105
|
return (
|
|
109
106
|
symbol +
|
package/src/qr-code-canvas.tsx
CHANGED
|
@@ -21,20 +21,19 @@ import {
|
|
|
21
21
|
useState,
|
|
22
22
|
} from "react";
|
|
23
23
|
import type { QRPropsCanvas, ReactQRElement } from "../types/react";
|
|
24
|
-
import qrcodegen from "./codegen";
|
|
25
24
|
import {
|
|
26
25
|
DEFAULT_BGCOLOR,
|
|
27
26
|
DEFAULT_FGCOLOR,
|
|
28
27
|
DEFAULT_LEVEL,
|
|
29
28
|
DEFAULT_MARGIN,
|
|
30
29
|
DEFAULT_SIZE,
|
|
31
|
-
ERROR_LEVEL_MAP,
|
|
32
30
|
} from "./constants";
|
|
33
31
|
import { drawFrameOnCanvas, getFrameLayout, isFrameActive } from "./frame";
|
|
34
32
|
import { logoImageBox, traceLogoShape } from "./logo";
|
|
35
33
|
import { capImageSettings } from "./logo-budget";
|
|
36
34
|
import { clampBgRadius } from "./looks";
|
|
37
35
|
import { getLayoutMargin, shapeBackground, shapeDecoration } from "./qr-shape";
|
|
36
|
+
import { encodeSymbol } from "./symbol";
|
|
38
37
|
import {
|
|
39
38
|
excavateModules,
|
|
40
39
|
generatePath,
|
|
@@ -74,6 +73,7 @@ export function QRCodeCanvas(props: QRPropsCanvas): ReactQRElement {
|
|
|
74
73
|
halo: _halo,
|
|
75
74
|
shadow: _shadow,
|
|
76
75
|
autoLevel,
|
|
76
|
+
exactLevel,
|
|
77
77
|
shape,
|
|
78
78
|
bgRadius,
|
|
79
79
|
backdrop,
|
|
@@ -83,7 +83,7 @@ export function QRCodeCanvas(props: QRPropsCanvas): ReactQRElement {
|
|
|
83
83
|
} = props;
|
|
84
84
|
// A logo no bigger than the code can repair (logo-budget.ts)
|
|
85
85
|
const imageSettings = capImageSettings(
|
|
86
|
-
{ value, size, margin, level, shape, autoLevel },
|
|
86
|
+
{ value, size, margin, level, shape, autoLevel, exactLevel },
|
|
87
87
|
requestedImageSettings
|
|
88
88
|
);
|
|
89
89
|
const effectiveLevel = resolveErrorLevel({
|
|
@@ -93,6 +93,7 @@ export function QRCodeCanvas(props: QRPropsCanvas): ReactQRElement {
|
|
|
93
93
|
margin,
|
|
94
94
|
imageSettings,
|
|
95
95
|
autoLevel,
|
|
96
|
+
exactLevel,
|
|
96
97
|
shape,
|
|
97
98
|
});
|
|
98
99
|
const imgSrc = imageSettings?.src;
|
|
@@ -121,10 +122,7 @@ export function QRCodeCanvas(props: QRPropsCanvas): ReactQRElement {
|
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
let cells =
|
|
125
|
-
value,
|
|
126
|
-
ERROR_LEVEL_MAP[effectiveLevel]
|
|
127
|
-
).getModules();
|
|
125
|
+
let cells = encodeSymbol(value, effectiveLevel, exactLevel).getModules();
|
|
128
126
|
|
|
129
127
|
// A shaped code (circle, heart, silhouette) sits further in, inside
|
|
130
128
|
// its outline, with decorative modules around its quiet ring
|
package/src/qr-code-props.ts
CHANGED
|
@@ -56,6 +56,7 @@ const QR_CODE_PROP_KEYS = {
|
|
|
56
56
|
eyeColors: true,
|
|
57
57
|
moduleScale: true,
|
|
58
58
|
autoLevel: true,
|
|
59
|
+
exactLevel: true,
|
|
59
60
|
shape: true,
|
|
60
61
|
eyeShapes: true,
|
|
61
62
|
eyeGradient: true,
|
|
@@ -111,6 +112,7 @@ export const QR_CODE_DATA_KEYS = [
|
|
|
111
112
|
"logoOptions",
|
|
112
113
|
"margin",
|
|
113
114
|
"autoLevel",
|
|
115
|
+
"exactLevel",
|
|
114
116
|
"shape",
|
|
115
117
|
"eyeShapes",
|
|
116
118
|
"eyeGradient",
|
|
@@ -149,6 +151,7 @@ export function getQRCodeSVGProps(
|
|
|
149
151
|
eyeColors,
|
|
150
152
|
moduleScale,
|
|
151
153
|
autoLevel,
|
|
154
|
+
exactLevel,
|
|
152
155
|
shape,
|
|
153
156
|
frameLabelMarkers,
|
|
154
157
|
partMarkers,
|
|
@@ -198,6 +201,7 @@ export function getQRCodeSVGProps(
|
|
|
198
201
|
...(eyeColors && { eyeColors }),
|
|
199
202
|
...(moduleScale !== undefined && { moduleScale }),
|
|
200
203
|
...(autoLevel && { autoLevel }),
|
|
204
|
+
...(exactLevel && { exactLevel }),
|
|
201
205
|
...(shape && shape !== "square" && { shape }),
|
|
202
206
|
...looks,
|
|
203
207
|
...(frameLabelMarkers && { frameLabelMarkers }),
|
package/src/scan-score.ts
CHANGED
|
@@ -4,13 +4,11 @@ import type { ColorConfig, QRProps } from "../types";
|
|
|
4
4
|
import { normalizeColorConfig } from "../types/color-helpers";
|
|
5
5
|
import { EYE_POSITIONS } from "../types/constants";
|
|
6
6
|
import type { QRArtPixels } from "./art";
|
|
7
|
-
import qrcodegen from "./codegen";
|
|
8
7
|
import {
|
|
9
8
|
DEFAULT_BGCOLOR,
|
|
10
9
|
DEFAULT_FGCOLOR,
|
|
11
10
|
DEFAULT_MARGIN,
|
|
12
11
|
DEFAULT_SIZE,
|
|
13
|
-
ERROR_LEVEL_MAP,
|
|
14
12
|
} from "./constants";
|
|
15
13
|
import { handleImageLoad } from "./detection";
|
|
16
14
|
import { withQRSize } from "./download";
|
|
@@ -24,6 +22,7 @@ import {
|
|
|
24
22
|
weakestEyePattern,
|
|
25
23
|
} from "./looks";
|
|
26
24
|
import { circleQuietZone, getLayoutMargin, isShapedCode } from "./qr-shape";
|
|
25
|
+
import { encodeSymbol } from "./symbol";
|
|
27
26
|
import { getTemplateCodeShare } from "./template-placement";
|
|
28
27
|
import { getImageSettings, getLuminance, resolveErrorLevel } from "./utils";
|
|
29
28
|
import { parseColor, type RGBAColor } from "./utils/parse-color";
|
|
@@ -702,9 +701,10 @@ function contrastChecks(
|
|
|
702
701
|
}
|
|
703
702
|
|
|
704
703
|
function moduleCount(props: QRProps) {
|
|
705
|
-
return
|
|
704
|
+
return encodeSymbol(
|
|
706
705
|
props.value,
|
|
707
|
-
|
|
706
|
+
resolveErrorLevel(props),
|
|
707
|
+
props.exactLevel
|
|
708
708
|
).getModules();
|
|
709
709
|
}
|
|
710
710
|
|
|
@@ -777,6 +777,7 @@ function logoCheck(props: QRProps): {
|
|
|
777
777
|
margin: props.margin ?? DEFAULT_MARGIN,
|
|
778
778
|
level,
|
|
779
779
|
shape: props.shape,
|
|
780
|
+
exactLevel: props.exactLevel,
|
|
780
781
|
},
|
|
781
782
|
imageSettings
|
|
782
783
|
);
|
package/src/symbol.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ErrorLevel } from "../types";
|
|
2
|
+
import qrcodegen from "./codegen";
|
|
3
|
+
import { ERROR_LEVEL_MAP } from "./constants";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The QR symbol for `value` at `level`, in the smallest version that holds
|
|
7
|
+
* it. Every renderer, the logo budget, the scan score and the print layout
|
|
8
|
+
* encode through here, so they all draw and judge the same symbol.
|
|
9
|
+
*
|
|
10
|
+
* The encoder raises the level to Q or H when the data still fits that
|
|
11
|
+
* version (more error correction for free); `exactLevel` keeps `level`, as
|
|
12
|
+
* a Swiss QR-bill needs (M). Without it this is QrCode.encodeText.
|
|
13
|
+
*/
|
|
14
|
+
export function encodeSymbol(
|
|
15
|
+
value: string,
|
|
16
|
+
level: ErrorLevel,
|
|
17
|
+
exactLevel?: boolean
|
|
18
|
+
): qrcodegen.QrCode {
|
|
19
|
+
return qrcodegen.QrCode.encodeSegments(
|
|
20
|
+
qrcodegen.QrSegment.makeSegments(value),
|
|
21
|
+
ERROR_LEVEL_MAP[level],
|
|
22
|
+
qrcodegen.QrCode.MIN_VERSION,
|
|
23
|
+
qrcodegen.QrCode.MAX_VERSION,
|
|
24
|
+
-1,
|
|
25
|
+
!exactLevel
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import type { QRProps } from "../../types";
|
|
2
2
|
import { isGradient } from "../../types/color-helpers";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_BGCOLOR,
|
|
6
|
-
DEFAULT_MARGIN,
|
|
7
|
-
DEFAULT_SIZE,
|
|
8
|
-
ERROR_LEVEL_MAP,
|
|
9
|
-
} from "../constants";
|
|
3
|
+
import { DEFAULT_BGCOLOR, DEFAULT_MARGIN, DEFAULT_SIZE } from "../constants";
|
|
10
4
|
import { withQRSize } from "../download";
|
|
11
5
|
import { getQRAsSVGDataUri } from "../export";
|
|
12
6
|
import { getFrameLayout, isFrameActive } from "../frame";
|
|
13
7
|
import { clampBgRadius } from "../looks";
|
|
14
8
|
import { getLayoutMargin } from "../qr-shape";
|
|
9
|
+
import { encodeSymbol } from "../symbol";
|
|
15
10
|
import { resolveErrorLevel } from "../utils";
|
|
16
11
|
import { getSolidColor } from "./color";
|
|
17
12
|
import { flattenOver } from "./paint";
|
|
@@ -43,9 +38,10 @@ export function getPrintBleedColor(props: QRProps): string | null {
|
|
|
43
38
|
}
|
|
44
39
|
// Outside rounded corners the backdrop shows, so the bleed continues it
|
|
45
40
|
if (props.backdrop && props.bgRadius) {
|
|
46
|
-
const modules =
|
|
41
|
+
const modules = encodeSymbol(
|
|
47
42
|
props.value,
|
|
48
|
-
|
|
43
|
+
resolveErrorLevel(props),
|
|
44
|
+
props.exactLevel
|
|
49
45
|
).size;
|
|
50
46
|
const margin = getLayoutMargin(
|
|
51
47
|
modules,
|