qrdx 0.0.60 → 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.
Files changed (102) hide show
  1. package/README.md +3 -2
  2. package/dist/angular.js +7 -2
  3. package/dist/angular.js.map +1 -1
  4. package/dist/angular.mjs +7 -2
  5. package/dist/angular.mjs.map +1 -1
  6. package/dist/core.js +7 -7
  7. package/dist/core.js.map +1 -1
  8. package/dist/core.mjs +7 -7
  9. package/dist/core.mjs.map +1 -1
  10. package/dist/element.browser.mjs +6 -6
  11. package/dist/element.browser.mjs.map +1 -1
  12. package/dist/element.js +1 -1
  13. package/dist/element.js.map +1 -1
  14. package/dist/element.mjs +1 -1
  15. package/dist/element.mjs.map +1 -1
  16. package/dist/index.js +7 -7
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +7 -7
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/node.js +2 -2
  21. package/dist/node.js.map +1 -1
  22. package/dist/node.mjs +2 -2
  23. package/dist/node.mjs.map +1 -1
  24. package/dist/qr-code-canvas.js +1 -1
  25. package/dist/qr-code-canvas.js.map +1 -1
  26. package/dist/qr-code-canvas.mjs +1 -1
  27. package/dist/qr-code-canvas.mjs.map +1 -1
  28. package/dist/schemas.js +1 -1
  29. package/dist/schemas.js.map +1 -1
  30. package/dist/schemas.mjs +1 -1
  31. package/dist/schemas.mjs.map +1 -1
  32. package/dist/src/angular.d.ts +2 -1
  33. package/dist/src/api.d.ts +2 -3
  34. package/dist/src/api.d.ts.map +1 -1
  35. package/dist/src/element.d.ts +2 -0
  36. package/dist/src/element.d.ts.map +1 -1
  37. package/dist/src/helpers.d.ts +2 -2
  38. package/dist/src/helpers.d.ts.map +1 -1
  39. package/dist/src/logo-budget.d.ts +3 -1
  40. package/dist/src/logo-budget.d.ts.map +1 -1
  41. package/dist/src/looks.d.ts +2 -2
  42. package/dist/src/looks.d.ts.map +1 -1
  43. package/dist/src/plain.d.ts.map +1 -1
  44. package/dist/src/print.d.ts.map +1 -1
  45. package/dist/src/qr-code-canvas.d.ts +2 -8
  46. package/dist/src/qr-code-canvas.d.ts.map +1 -1
  47. package/dist/src/qr-code-props.d.ts +1 -1
  48. package/dist/src/qr-code-props.d.ts.map +1 -1
  49. package/dist/src/qr-code-svg.d.ts +2 -3
  50. package/dist/src/qr-code-svg.d.ts.map +1 -1
  51. package/dist/src/qr-code.d.ts +2 -2
  52. package/dist/src/qr-code.d.ts.map +1 -1
  53. package/dist/src/qr-frame-svg.d.ts +2 -3
  54. package/dist/src/qr-frame-svg.d.ts.map +1 -1
  55. package/dist/src/rasterize.d.ts +8 -0
  56. package/dist/src/rasterize.d.ts.map +1 -1
  57. package/dist/src/react-elements.d.ts.map +1 -1
  58. package/dist/src/scan-score.d.ts +34 -0
  59. package/dist/src/scan-score.d.ts.map +1 -1
  60. package/dist/src/symbol.d.ts +13 -0
  61. package/dist/src/symbol.d.ts.map +1 -0
  62. package/dist/src/utils/print-shared.d.ts.map +1 -1
  63. package/dist/src/utils.d.ts +1 -0
  64. package/dist/src/utils.d.ts.map +1 -1
  65. package/dist/src/vue.d.ts.map +1 -1
  66. package/dist/types/index.js +1 -1
  67. package/dist/types/index.js.map +1 -1
  68. package/dist/types/index.mjs +1 -1
  69. package/dist/types/index.mjs.map +1 -1
  70. package/dist/types/qr.d.ts +2 -0
  71. package/dist/types/qr.d.ts.map +1 -1
  72. package/dist/types/react.d.ts +21 -3
  73. package/dist/types/react.d.ts.map +1 -1
  74. package/dist/vanilla.browser.mjs +16 -16
  75. package/dist/vanilla.browser.mjs.map +1 -1
  76. package/dist/vue.js +1 -1
  77. package/dist/vue.js.map +1 -1
  78. package/dist/vue.mjs +1 -1
  79. package/dist/vue.mjs.map +1 -1
  80. package/package.json +4 -6
  81. package/src/angular.ts +2 -0
  82. package/src/api.tsx +3 -4
  83. package/src/element.ts +3 -0
  84. package/src/helpers.ts +27 -10
  85. package/src/logo-budget.ts +9 -8
  86. package/src/looks.ts +17 -14
  87. package/src/plain.tsx +5 -7
  88. package/src/print.ts +3 -6
  89. package/src/qr-code-canvas.tsx +39 -34
  90. package/src/qr-code-props.ts +4 -0
  91. package/src/qr-code-svg.tsx +3 -4
  92. package/src/qr-code.tsx +7 -5
  93. package/src/qr-frame-svg.tsx +3 -4
  94. package/src/rasterize.ts +14 -1
  95. package/src/react-elements.ts +40 -2
  96. package/src/scan-score.ts +225 -51
  97. package/src/symbol.ts +27 -0
  98. package/src/utils/print-shared.ts +5 -9
  99. package/src/utils.tsx +9 -9
  100. package/src/vue.ts +1 -0
  101. package/types/qr.ts +6 -0
  102. package/types/react.ts +22 -3
package/dist/vue.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var vue=require('vue'),core_js=require('./core.js');var s={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:s,templateId:null,customTemplate:null,customProps:null,frame:null,art:null,eyeColors:null,moduleScale:Number,autoLevel:s,shape:null,eyeShapes:null,eyeGradient:null,bgRadius:Number,backdrop:null,halo:null,shadow:null,frameLabelMarkers:s,partMarkers:s},G={...C,logo:String,logoOptions:null,hideLogo:s,scale:Number},b=t=>/^on[^a-z]/.test(t);function y(t,e){let o=core_js.toHyperscript(core_js.createQRCodeTree({...t,...e}),(l,i,c,a)=>vue.h(l,a===null?i:{...i,key:a},c)),n=null;for(let l of Object.keys(e))b(l)&&(n??={},n[l]=e[l]);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 x=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=x;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
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,C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AAA,CACR0B,CAAAA,CACAR,EAAWlB,CAAAA,CAAQ,KAAA,CAAO2B,EAAc,IAAI,CAAA,CAC5C,CAAE,OAAA,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"}
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,CA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ACF,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 s={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:s,templateId:null,customTemplate:null,customProps:null,frame:null,art:null,eyeColors:null,moduleScale:Number,autoLevel:s,shape:null,eyeShapes:null,eyeGradient:null,bgRadius:Number,backdrop:null,halo:null,shadow:null,frameLabelMarkers:s,partMarkers:s},G={...C,logo:String,logoOptions:null,hideLogo:s,scale:Number},b=t=>/^on[^a-z]/.test(t);function y(t,e){let o=toHyperscript(createQRCodeTree({...t,...e}),(l,i,c,a)=>h(l,a===null?i:{...i,key:a},c)),n=null;for(let l of Object.keys(e))b(l)&&(n??={},n[l]=e[l]);let[r]=o;return n&&isVNode(r)&&(o[0]=h(r.type,{...r.props,...n},r.children)),o.length===1?o[0]:o}var x=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,x as QRCodeSVG,w as useQRCode};//# sourceMappingURL=vue.mjs.map
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,MAAO,IAAA,CACP,SAAA,CAAW,KACX,WAAA,CAAa,IAAA,CACb,QAAA,CAAU,MAAA,CACV,SAAU,IAAA,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,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.mjs"}
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,CAC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A,CAAAA,CAAgB,SAC1B,OAAA,CAASA,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.60",
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",
@@ -199,6 +199,7 @@
199
199
  "test": "vitest run",
200
200
  "readme": "node scripts/readme-catalogue.mjs",
201
201
  "check:package": "node scripts/check-package.mjs",
202
+ "check:react": "node scripts/react-compat.mjs",
202
203
  "prepublishOnly": "node -e \"if(!(process.env.npm_config_user_agent||'').startsWith('bun/')){console.error('Publish through the Publish workflow, or with bun publish, which replaces workspace ranges with real versions.');process.exit(1)}\" && bun run build && bun run test && node scripts/readme-catalogue.mjs --check"
203
204
  },
204
205
  "dependencies": {
@@ -218,6 +219,7 @@
218
219
  "next": "16.4.5",
219
220
  "publint": "0.3.25",
220
221
  "react": "^19.3.1",
222
+ "react-dom": "^19.3.1",
221
223
  "sharp": "0.35.5",
222
224
  "tsup": "^9.0.0",
223
225
  "typescript": "6.0.3",
@@ -238,8 +240,7 @@
238
240
  "peerDependencies": {
239
241
  "@resvg/resvg-js": "^2.6.2",
240
242
  "jspdf": "^2.5.0 || ^3.0.0 || ^4.0.0",
241
- "react": ">=18.0.0",
242
- "react-dom": ">=18.0.0",
243
+ "react": ">=16.8.0",
243
244
  "sharp": ">=0.34.0",
244
245
  "vue": ">=3.3.0",
245
246
  "preact": ">=10.0.0",
@@ -256,9 +257,6 @@
256
257
  "react": {
257
258
  "optional": true
258
259
  },
259
- "react-dom": {
260
- "optional": true
261
- },
262
260
  "sharp": {
263
261
  "optional": true
264
262
  },
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/api.tsx CHANGED
@@ -1,5 +1,4 @@
1
- import type { JSX } from "react";
2
- import type { QRPropsSVG } from "../types/react";
1
+ import type { QRPropsSVG, ReactQRElement } from "../types/react";
3
2
  import { withElementFactory } from "./jsx/runtime";
4
3
  import { drawPlainQRCode, preparePlainQRCode } from "./plain";
5
4
  import { REACT_ELEMENTS } from "./react-elements";
@@ -9,9 +8,9 @@ import { REACT_ELEMENTS } from "./react-elements";
9
8
  * background rect, plus the logo and frame (`getQRAsSVGNode` is the same
10
9
  * without React). A logo that isn't a data URL is fetched as base64 first.
11
10
  */
12
- export async function getQRAsSVG(props: QRPropsSVG): Promise<JSX.Element> {
11
+ export async function getQRAsSVG(props: QRPropsSVG): Promise<ReactQRElement> {
13
12
  const plain = await preparePlainQRCode(props);
14
13
  return withElementFactory(REACT_ELEMENTS, () =>
15
14
  drawPlainQRCode(plain)
16
- ) as unknown as JSX.Element;
15
+ ) as unknown as ReactQRElement;
17
16
  }
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 qrcodegen from "./codegen";
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(value: string, level: QRProps["level"]): number {
25
- return qrcodegen.QrCode.encodeText(
26
- value,
27
- ERROR_LEVEL_MAP[level ?? DEFAULT_LEVEL]
28
- ).size;
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<QRProps, "value" | "level" | "margin" | "shape" | "autoLevel"> & {
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
- { value: `${value}`, size, margin: margin ?? DEFAULT_MARGIN, level, shape },
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 }),
@@ -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, ERROR_LEVEL_MAP } from "./constants";
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 = qrcodegen.QrCode.encodeText(
55
- code.value,
56
- ERROR_LEVEL_MAP[code.level]
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 qrcodegen from "./codegen";
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 `autoLevel`, the logo is held to its budget
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
- { value: `${value}`, size, margin, level, shape, autoLevel, isOGContext },
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 = qrcodegen.QrCode.encodeText(
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 = qrcodegen.QrCode.encodeText(
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 qrcodegen from "./codegen";
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 = qrcodegen.QrCode.encodeText(
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 +
@@ -10,22 +10,30 @@
10
10
  * Copyright (c) Paul O'Shannessy
11
11
  * SPDX-License-Identifier: ISC
12
12
  */
13
- import { type JSX, useEffect, useRef, useState } from "react";
14
- import type { QRPropsCanvas } from "../types/react";
15
- import qrcodegen from "./codegen";
13
+ // createElement rather than JSX: compiled JSX would import
14
+ // react/jsx-runtime, which React has had only since 16.14.
15
+ import {
16
+ createElement,
17
+ Fragment,
18
+ type ReactElement,
19
+ useEffect,
20
+ useRef,
21
+ useState,
22
+ } from "react";
23
+ import type { QRPropsCanvas, ReactQRElement } from "../types/react";
16
24
  import {
17
25
  DEFAULT_BGCOLOR,
18
26
  DEFAULT_FGCOLOR,
19
27
  DEFAULT_LEVEL,
20
28
  DEFAULT_MARGIN,
21
29
  DEFAULT_SIZE,
22
- ERROR_LEVEL_MAP,
23
30
  } from "./constants";
24
31
  import { drawFrameOnCanvas, getFrameLayout, isFrameActive } from "./frame";
25
32
  import { logoImageBox, traceLogoShape } from "./logo";
26
33
  import { capImageSettings } from "./logo-budget";
27
34
  import { clampBgRadius } from "./looks";
28
35
  import { getLayoutMargin, shapeBackground, shapeDecoration } from "./qr-shape";
36
+ import { encodeSymbol } from "./symbol";
29
37
  import {
30
38
  excavateModules,
31
39
  generatePath,
@@ -35,7 +43,7 @@ import {
35
43
  } from "./utils";
36
44
  import { getSolidColor } from "./utils/color";
37
45
 
38
- export function QRCodeCanvas(props: QRPropsCanvas) {
46
+ export function QRCodeCanvas(props: QRPropsCanvas): ReactQRElement {
39
47
  const {
40
48
  value,
41
49
  size = DEFAULT_SIZE,
@@ -65,6 +73,7 @@ export function QRCodeCanvas(props: QRPropsCanvas) {
65
73
  halo: _halo,
66
74
  shadow: _shadow,
67
75
  autoLevel,
76
+ exactLevel,
68
77
  shape,
69
78
  bgRadius,
70
79
  backdrop,
@@ -74,7 +83,7 @@ export function QRCodeCanvas(props: QRPropsCanvas) {
74
83
  } = props;
75
84
  // A logo no bigger than the code can repair (logo-budget.ts)
76
85
  const imageSettings = capImageSettings(
77
- { value, size, margin, level, shape, autoLevel },
86
+ { value, size, margin, level, shape, autoLevel, exactLevel },
78
87
  requestedImageSettings
79
88
  );
80
89
  const effectiveLevel = resolveErrorLevel({
@@ -84,6 +93,7 @@ export function QRCodeCanvas(props: QRPropsCanvas) {
84
93
  margin,
85
94
  imageSettings,
86
95
  autoLevel,
96
+ exactLevel,
87
97
  shape,
88
98
  });
89
99
  const imgSrc = imageSettings?.src;
@@ -112,10 +122,7 @@ export function QRCodeCanvas(props: QRPropsCanvas) {
112
122
  return;
113
123
  }
114
124
 
115
- let cells = qrcodegen.QrCode.encodeText(
116
- value,
117
- ERROR_LEVEL_MAP[effectiveLevel]
118
- ).getModules();
125
+ let cells = encodeSymbol(value, effectiveLevel, exactLevel).getModules();
119
126
 
120
127
  // A shaped code (circle, heart, silhouette) sits further in, inside
121
128
  // its outline, with decorative modules around its quiet ring
@@ -233,31 +240,29 @@ export function QRCodeCanvas(props: QRPropsCanvas) {
233
240
  });
234
241
 
235
242
  const canvasStyle = { height: outputHeight, width: outputWidth, ...style };
236
- let img: JSX.Element | null = null;
243
+ let img: ReactElement | null = null;
237
244
  if (imgSrc != null) {
238
- img = (
239
- <img
240
- alt="QR code"
241
- key={imgSrc}
242
- onLoad={() => {
243
- setIsImageLoaded(true);
244
- }}
245
- ref={_image}
246
- src={imgSrc}
247
- style={{ display: "none" }}
248
- />
249
- );
245
+ img = createElement("img", {
246
+ alt: "QR code",
247
+ key: imgSrc,
248
+ onLoad: () => {
249
+ setIsImageLoaded(true);
250
+ },
251
+ ref: _image,
252
+ src: imgSrc,
253
+ style: { display: "none" },
254
+ });
250
255
  }
251
- return (
252
- <>
253
- <canvas
254
- height={outputHeight}
255
- ref={_canvas}
256
- style={canvasStyle}
257
- width={outputWidth}
258
- {...otherProps}
259
- />
260
- {img}
261
- </>
256
+ return createElement(
257
+ Fragment,
258
+ null,
259
+ createElement("canvas", {
260
+ height: outputHeight,
261
+ ref: _canvas,
262
+ style: canvasStyle,
263
+ width: outputWidth,
264
+ ...otherProps,
265
+ }),
266
+ img
262
267
  );
263
268
  }
@@ -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 }),