qrdx 0.0.56 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -6
- package/dist/angular.js +33 -3
- package/dist/angular.js.map +1 -1
- package/dist/angular.mjs +33 -3
- package/dist/angular.mjs.map +1 -1
- package/dist/core.js +7 -7
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +7 -7
- package/dist/core.mjs.map +1 -1
- package/dist/element.browser.mjs +6 -6
- package/dist/element.browser.mjs.map +1 -1
- package/dist/element.js +1 -1
- package/dist/element.js.map +1 -1
- package/dist/element.mjs +1 -1
- package/dist/element.mjs.map +1 -1
- package/dist/frames-index.js +1 -1
- package/dist/frames-index.js.map +1 -1
- package/dist/frames-index.mjs +1 -1
- package/dist/frames-index.mjs.map +1 -1
- package/dist/frames-official.js +1 -1
- package/dist/frames-official.js.map +1 -1
- package/dist/frames-official.mjs +1 -1
- package/dist/frames-official.mjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/dist/qr-code-canvas.js +1 -1
- package/dist/qr-code-canvas.js.map +1 -1
- package/dist/qr-code-canvas.mjs +1 -1
- package/dist/qr-code-canvas.mjs.map +1 -1
- package/dist/schemas.js +1 -1
- package/dist/schemas.js.map +1 -1
- package/dist/schemas.mjs +1 -1
- package/dist/schemas.mjs.map +1 -1
- package/dist/src/angular.d.ts +9 -3
- package/dist/src/bmp.d.ts +7 -0
- package/dist/src/bmp.d.ts.map +1 -0
- package/dist/src/download.d.ts +39 -6
- package/dist/src/download.d.ts.map +1 -1
- package/dist/src/element.d.ts +10 -1
- package/dist/src/element.d.ts.map +1 -1
- package/dist/src/engine.d.ts +6 -2
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/eps.d.ts.map +1 -1
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/frame.d.ts +24 -0
- package/dist/src/frame.d.ts.map +1 -1
- package/dist/src/frames/catalogue/all.d.ts.map +1 -1
- package/dist/src/frames/catalogue/batches.d.ts +6 -0
- package/dist/src/frames/catalogue/batches.d.ts.map +1 -0
- package/dist/src/frames/catalogue/call-to-action.d.ts.map +1 -1
- package/dist/src/frames/catalogue/counts.d.ts +4 -2
- package/dist/src/frames/catalogue/counts.d.ts.map +1 -1
- package/dist/src/frames/catalogue/index.d.ts.map +1 -1
- package/dist/src/frames/catalogue/objects.d.ts +5 -0
- package/dist/src/frames/catalogue/objects.d.ts.map +1 -0
- package/dist/src/frames/catalogue/playful.d.ts +5 -0
- package/dist/src/frames/catalogue/playful.d.ts.map +1 -0
- package/dist/src/frames/catalogue/tags.d.ts.map +1 -1
- package/dist/src/frames/collections.d.ts.map +1 -1
- package/dist/src/frames/official-types.d.ts +1 -1
- package/dist/src/frames/official-types.d.ts.map +1 -1
- package/dist/src/frames/official.d.ts.map +1 -1
- package/dist/src/gif.d.ts +40 -0
- package/dist/src/gif.d.ts.map +1 -0
- package/dist/src/helpers.d.ts +1 -1
- package/dist/src/helpers.d.ts.map +1 -1
- package/dist/src/ico.d.ts +11 -0
- package/dist/src/ico.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/looks.d.ts +101 -0
- package/dist/src/looks.d.ts.map +1 -0
- package/dist/src/plain.d.ts.map +1 -1
- package/dist/src/print.d.ts.map +1 -1
- package/dist/src/qr-code-canvas.d.ts.map +1 -1
- package/dist/src/qr-code-props.d.ts.map +1 -1
- package/dist/src/qr-frame-svg.d.ts +10 -0
- package/dist/src/qr-frame-svg.d.ts.map +1 -0
- package/dist/src/scan-score.d.ts.map +1 -1
- package/dist/src/utils/bmp.d.ts +18 -0
- package/dist/src/utils/bmp.d.ts.map +1 -0
- package/dist/src/utils/gif.d.ts +61 -0
- package/dist/src/utils/gif.d.ts.map +1 -0
- package/dist/src/utils/ico.d.ts +30 -0
- package/dist/src/utils/ico.d.ts.map +1 -0
- package/dist/src/utils/parse-color.d.ts +1 -1
- package/dist/src/utils/parse-color.d.ts.map +1 -1
- package/dist/src/utils/print-shared.d.ts.map +1 -1
- package/dist/src/utils/svg-painter.d.ts +13 -0
- package/dist/src/utils/svg-painter.d.ts.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/vanilla-api.d.ts +2 -2
- package/dist/src/vanilla-api.d.ts.map +1 -1
- package/dist/src/vue.d.ts +2 -2
- package/dist/src/vue.d.ts.map +1 -1
- package/dist/types/constants.d.ts +41 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/index.js +2 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +2 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/plain.d.ts +2 -2
- package/dist/types/plain.d.ts.map +1 -1
- package/dist/types/qr.d.ts +399 -1
- package/dist/types/qr.d.ts.map +1 -1
- package/dist/types/react.d.ts +10 -1
- package/dist/types/react.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +1 -1
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/vanilla.browser.mjs +34 -34
- package/dist/vanilla.browser.mjs.map +1 -1
- package/dist/vue.js +1 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +1 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +6 -2
- package/src/angular.ts +14 -2
- package/src/bmp.ts +25 -0
- package/src/download.tsx +128 -8
- package/src/element.ts +16 -1
- package/src/engine.ts +23 -0
- package/src/eps.ts +8 -1
- package/src/export.ts +22 -0
- package/src/frame.tsx +51 -0
- package/src/frames/catalogue/all.ts +202 -0
- package/src/frames/catalogue/batches.ts +114 -0
- package/src/frames/catalogue/call-to-action.ts +58 -0
- package/src/frames/catalogue/counts.ts +4 -2
- package/src/frames/catalogue/index.ts +808 -0
- package/src/frames/catalogue/objects.ts +65 -0
- package/src/frames/catalogue/playful.ts +97 -0
- package/src/frames/catalogue/tags.ts +137 -0
- package/src/frames/collections.ts +2 -0
- package/src/frames/official/badge-bottom-light.json +91 -0
- package/src/frames/official/badge-bottom.json +79 -0
- package/src/frames/official/billboard-campaign.json +274 -0
- package/src/frames/official/billboard-light.json +287 -0
- package/src/frames/official/bookmark-light.json +88 -0
- package/src/frames/official/bookmark-strip.json +83 -0
- package/src/frames/official/border-medium.json +71 -0
- package/src/frames/official/border-thick.json +71 -0
- package/src/frames/official/border-thin.json +71 -0
- package/src/frames/official/bottle-label.json +136 -0
- package/src/frames/official/bottle-light.json +133 -0
- package/src/frames/official/camera-viewfinder.json +174 -0
- package/src/frames/official/cassette-tape.json +236 -0
- package/src/frames/official/cat-with-card-light.json +246 -0
- package/src/frames/official/cat-with-card.json +234 -0
- package/src/frames/official/cinema-marquee.json +537 -0
- package/src/frames/official/circle-viewfinder.json +87 -0
- package/src/frames/official/clapperboard-light.json +163 -0
- package/src/frames/official/clapperboard-scene.json +151 -0
- package/src/frames/official/comic-panel.json +386 -0
- package/src/frames/official/corner-tab-light.json +101 -0
- package/src/frames/official/corner-tab.json +89 -0
- package/src/frames/official/crystal-ball.json +105 -0
- package/src/frames/official/delivery-box-light.json +132 -0
- package/src/frames/official/delivery-box-track.json +132 -0
- package/src/frames/official/fish-tank.json +276 -0
- package/src/frames/official/flag-light.json +136 -0
- package/src/frames/official/flag-team.json +127 -0
- package/src/frames/official/floppy-disk.json +106 -0
- package/src/frames/official/flying-saucer.json +128 -0
- package/src/frames/official/gallery-frame.json +195 -0
- package/src/frames/official/globe-stand.json +136 -0
- package/src/frames/official/gumball-machine.json +451 -0
- package/src/frames/official/heart-light.json +59 -0
- package/src/frames/official/heart-scan.json +51 -0
- package/src/frames/official/hexagon-light.json +87 -0
- package/src/frames/official/hexagon-scan.json +72 -0
- package/src/frames/official/hot-air-balloon.json +132 -0
- package/src/frames/official/jigsaw-piece-light.json +68 -0
- package/src/frames/official/jigsaw-piece.json +60 -0
- package/src/frames/official/laptop-screen.json +137 -0
- package/src/frames/official/lighthouse-tower.json +132 -0
- package/src/frames/official/magnifying-glass.json +85 -0
- package/src/frames/official/mailbox-flag.json +112 -0
- package/src/frames/official/mailbox-light.json +120 -0
- package/src/frames/official/map-pin-light.json +76 -0
- package/src/frames/official/map-pin.json +58 -0
- package/src/frames/official/matchbox-drawer.json +170 -0
- package/src/frames/official/microwave-door.json +220 -0
- package/src/frames/official/milk-carton.json +129 -0
- package/src/frames/official/monitor-screen.json +111 -0
- package/src/frames/official/monster-mouth.json +180 -0
- package/src/frames/official/mug-light.json +138 -0
- package/src/frames/official/mug-refill.json +125 -0
- package/src/frames/official/museum-plaque-light.json +187 -0
- package/src/frames/official/museum-plaque.json +187 -0
- package/src/frames/official/music-player-light.json +151 -0
- package/src/frames/official/music-player.json +136 -0
- package/src/frames/official/octagon-light.json +126 -0
- package/src/frames/official/octagon-sign.json +120 -0
- package/src/frames/official/open-book.json +156 -0
- package/src/frames/official/parking-meter.json +107 -0
- package/src/frames/official/passport-stamp.json +132 -0
- package/src/frames/official/pizza-box.json +122 -0
- package/src/frames/official/polka-dot-border.json +502 -0
- package/src/frames/official/popcorn-bucket.json +305 -0
- package/src/frames/official/porthole.json +264 -0
- package/src/frames/official/raised-card-thin.json +111 -0
- package/src/frames/official/raised-card.json +99 -0
- package/src/frames/official/retro-radio.json +180 -0
- package/src/frames/official/ribbon-top-light.json +125 -0
- package/src/frames/official/ribbon-top.json +113 -0
- package/src/frames/official/robot-chest.json +197 -0
- package/src/frames/official/roll-up-banner-light.json +137 -0
- package/src/frames/official/roll-up-banner.json +125 -0
- package/src/frames/official/round-tag-light.json +86 -0
- package/src/frames/official/round-tag.json +79 -0
- package/src/frames/official/sailboat-sail.json +99 -0
- package/src/frames/official/scroll-story.json +184 -0
- package/src/frames/official/sketch-border.json +92 -0
- package/src/frames/official/sketch-circle.json +57 -0
- package/src/frames/official/snow-globe.json +170 -0
- package/src/frames/official/soda-can.json +160 -0
- package/src/frames/official/spin-rays.json +126 -0
- package/src/frames/official/spiral-notebook.json +476 -0
- package/src/frames/official/stage-curtains.json +303 -0
- package/src/frames/official/starburst-light.json +128 -0
- package/src/frames/official/starburst.json +118 -0
- package/src/frames/official/swirl-border.json +122 -0
- package/src/frames/official/tablet-screen.json +130 -0
- package/src/frames/official/text-frame.json +79 -0
- package/src/frames/official/toaster-toast.json +114 -0
- package/src/frames/official/train-window.json +176 -0
- package/src/frames/official/treasure-map.json +207 -0
- package/src/frames/official/tv-set.json +256 -0
- package/src/frames/official/vending-machine.json +218 -0
- package/src/frames/official/video-player.json +118 -0
- package/src/frames/official/video-tape.json +137 -0
- package/src/frames/official/vinyl-sleeve-light.json +139 -0
- package/src/frames/official/vinyl-sleeve.json +127 -0
- package/src/frames/official/washing-machine.json +146 -0
- package/src/frames/official-types.ts +3 -1
- package/src/frames/official.ts +4 -3
- package/src/gif.ts +188 -0
- package/src/helpers.ts +12 -0
- package/src/ico.ts +55 -0
- package/src/index.tsx +2 -0
- package/src/looks.ts +467 -0
- package/src/plain.tsx +6 -0
- package/src/print.ts +12 -0
- package/src/qr-code-canvas.tsx +23 -2
- package/src/qr-code-props.ts +22 -0
- package/src/qr-frame-svg.tsx +26 -0
- package/src/scan-score.ts +38 -6
- package/src/utils/bmp.ts +126 -0
- package/src/utils/gif.ts +632 -0
- package/src/utils/ico.ts +150 -0
- package/src/utils/parse-color.ts +163 -23
- package/src/utils/print-shared.ts +25 -1
- package/src/utils/svg-painter.ts +18 -0
- package/src/utils.tsx +136 -17
- package/src/vanilla-api.ts +2 -2
- package/src/vue.ts +8 -2
- package/types/constants.ts +47 -0
- package/types/plain.ts +19 -0
- package/types/qr.ts +98 -0
- package/types/react.ts +11 -1
- package/types/schemas.ts +5 -0
package/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},
|
|
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
|
|
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,
|
|
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,MAAO,IAAA,CACP,SAAA,CAAW,KACX,WAAA,CAAa,IAAA,CACb,QAAA,CAAU,MAAA,CACV,SAAU,IAAA,CACV,IAAA,CAAM,KACN,MAAA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B,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},
|
|
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
|
|
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,
|
|
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,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Q,KAAK,CAAC,CAAA,CACrD,OAAO,CACL,OAAA,CAAAA,CAAAA,CACA,IAAAwB,CAAAA,CACA,SAAA,CAAUE,EAAS,KAAA,CAAOC,CAAAA,CAAgB,EAAC,CAAG,CAC5C,OAAOC,gBAAAA,CACL5B,CAAAA,CAAQ,KAAA,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,cAAAA,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.mjs"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qrdx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
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",
|
|
@@ -198,6 +198,7 @@
|
|
|
198
198
|
"typecheck": "tsc --noEmit",
|
|
199
199
|
"test": "vitest run",
|
|
200
200
|
"readme": "node scripts/readme-catalogue.mjs",
|
|
201
|
+
"check:package": "node scripts/check-package.mjs",
|
|
201
202
|
"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"
|
|
202
203
|
},
|
|
203
204
|
"dependencies": {
|
|
@@ -206,6 +207,7 @@
|
|
|
206
207
|
"zod": "^4.6.7"
|
|
207
208
|
},
|
|
208
209
|
"devDependencies": {
|
|
210
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
209
211
|
"@repo/typescript-config": "0.0.0",
|
|
210
212
|
"@resvg/resvg-js": "^2.6.2",
|
|
211
213
|
"@types/node": "26.6.6",
|
|
@@ -214,6 +216,7 @@
|
|
|
214
216
|
"jsdom": "28.1.0",
|
|
215
217
|
"jspdf": "^4.2.1",
|
|
216
218
|
"next": "16.4.5",
|
|
219
|
+
"publint": "0.3.25",
|
|
217
220
|
"react": "^19.3.1",
|
|
218
221
|
"sharp": "0.35.5",
|
|
219
222
|
"tsup": "^9.0.0",
|
|
@@ -229,7 +232,8 @@
|
|
|
229
232
|
"@angular/core": "21.2.26",
|
|
230
233
|
"@angular/platform-browser": "21.2.26",
|
|
231
234
|
"@angular/platform-server": "21.2.26",
|
|
232
|
-
"rxjs": "^7.8.2"
|
|
235
|
+
"rxjs": "^7.8.2",
|
|
236
|
+
"zxing-wasm": "3.1.6"
|
|
233
237
|
},
|
|
234
238
|
"peerDependencies": {
|
|
235
239
|
"@resvg/resvg-js": "^2.6.2",
|
package/src/angular.ts
CHANGED
|
@@ -42,7 +42,7 @@ export interface QRCodeExportOptions {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface QRCodeDownloadOptions extends QRCodeExportOptions {
|
|
45
|
-
/** "png" (default), "jpg", "webp", "svg", "pdf" (needs jspdf) or "eps" */
|
|
45
|
+
/** "png" (default), "jpg", "webp", "bmp", "ico", "gif", "svg", "pdf" (needs jspdf) or "eps" */
|
|
46
46
|
format?: DownloadFormat;
|
|
47
47
|
/** File name; defaults to one with the format and pixel size */
|
|
48
48
|
filename?: string;
|
|
@@ -94,6 +94,12 @@ export class QRCode implements QRCodeInputs {
|
|
|
94
94
|
readonly margin: Prop<"margin"> = input();
|
|
95
95
|
readonly moduleScale: Prop<"moduleScale"> = input();
|
|
96
96
|
readonly shape: Prop<"shape"> = input();
|
|
97
|
+
readonly eyeShapes: Prop<"eyeShapes"> = input();
|
|
98
|
+
readonly eyeGradient: Prop<"eyeGradient"> = input();
|
|
99
|
+
readonly bgRadius: Prop<"bgRadius"> = input();
|
|
100
|
+
readonly backdrop: Prop<"backdrop"> = input();
|
|
101
|
+
readonly halo: Prop<"halo"> = input();
|
|
102
|
+
readonly shadow: Prop<"shadow"> = input();
|
|
97
103
|
readonly frame: Prop<"frame"> = input();
|
|
98
104
|
readonly art: Prop<"art"> = input();
|
|
99
105
|
readonly logo: Prop<"logo"> = input();
|
|
@@ -130,6 +136,12 @@ export class QRCode implements QRCodeInputs {
|
|
|
130
136
|
margin: this.margin(),
|
|
131
137
|
moduleScale: this.moduleScale(),
|
|
132
138
|
shape: this.shape(),
|
|
139
|
+
eyeShapes: this.eyeShapes(),
|
|
140
|
+
eyeGradient: this.eyeGradient(),
|
|
141
|
+
bgRadius: this.bgRadius(),
|
|
142
|
+
backdrop: this.backdrop(),
|
|
143
|
+
halo: this.halo(),
|
|
144
|
+
shadow: this.shadow(),
|
|
133
145
|
frame: this.frame(),
|
|
134
146
|
art: this.art(),
|
|
135
147
|
logo: this.logo(),
|
|
@@ -171,7 +183,7 @@ export class QRCode implements QRCodeInputs {
|
|
|
171
183
|
return this.element;
|
|
172
184
|
}
|
|
173
185
|
|
|
174
|
-
/** The code as a data URL: "png" (default), "jpg", "webp", "svg", "pdf" or "eps" */
|
|
186
|
+
/** The code as a data URL: "png" (default), "jpg", "webp", "bmp", "ico", "gif", "svg", "pdf" or "eps" */
|
|
175
187
|
toDataURL(
|
|
176
188
|
format: DownloadFormat = "png",
|
|
177
189
|
options: QRCodeExportOptions = {}
|
package/src/bmp.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// BMP from a canvas in any browser. No browser encodes BMP from a canvas
|
|
2
|
+
// (toBlob("image/bmp") returns a PNG), so the pixels are read back and written
|
|
3
|
+
// by the built-in encoder (utils/bmp.ts). The file is checked by its bytes
|
|
4
|
+
// before it is returned, so a PNG is never passed off as BMP.
|
|
5
|
+
|
|
6
|
+
import { encodeBMP, isBMPFile } from "./utils/bmp";
|
|
7
|
+
|
|
8
|
+
export { BMP_MAX_DIMENSION, encodeBMP, isBMPFile } from "./utils/bmp";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A canvas as a 24-bit BMP. A transparent background is laid over white,
|
|
12
|
+
* since 24-bit BMP has no alpha channel.
|
|
13
|
+
*/
|
|
14
|
+
export function canvasToBMP(canvas: HTMLCanvasElement): Blob {
|
|
15
|
+
const context = canvas.getContext("2d");
|
|
16
|
+
if (!context) {
|
|
17
|
+
throw new Error("Could not get canvas context");
|
|
18
|
+
}
|
|
19
|
+
const { data } = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
20
|
+
const file = encodeBMP(data, canvas.width, canvas.height);
|
|
21
|
+
if (!isBMPFile(file)) {
|
|
22
|
+
throw new Error("Could not write a BMP file");
|
|
23
|
+
}
|
|
24
|
+
return new Blob([file as BlobPart], { type: "image/bmp" });
|
|
25
|
+
}
|
package/src/download.tsx
CHANGED
|
@@ -1,34 +1,65 @@
|
|
|
1
1
|
import type { QRProps } from "../types";
|
|
2
|
+
import { canvasToBMP } from "./bmp";
|
|
2
3
|
import { DEFAULT_SIZE } from "./constants";
|
|
3
4
|
import { epsToDataUrl, getQRAsEPS } from "./eps";
|
|
4
5
|
import { getQRAsCanvas, getQRAsSVGDataUri } from "./export";
|
|
5
6
|
import { getFrameDimensions } from "./frame";
|
|
7
|
+
import { canvasToGIF, GIF_MIME } from "./gif";
|
|
8
|
+
import { canvasesToICO, ICO_MIME, ICO_SIZES } from "./ico";
|
|
6
9
|
import { blobToDataUrl, canvasToWebP, type WebPOptions } from "./webp";
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
|
-
* "webp" is lossless unless `quality` is set. "
|
|
10
|
-
*
|
|
12
|
+
* "webp" is lossless unless `quality` is set. "bmp" is an uncompressed
|
|
13
|
+
* 24-bit bitmap: a transparent background comes out white. "gif" keeps a
|
|
14
|
+
* transparent background as GIF's one transparent color and holds at most
|
|
15
|
+
* 256 colors: a design that needs more is reduced, and refused (a
|
|
16
|
+
* GIFScanError) when the reduced image would no longer scan. "ico" is one
|
|
17
|
+
* favicon file holding the code at 16, 32, 48 and 256 px, each an embedded
|
|
18
|
+
* PNG with its transparency; `size` doesn't apply, and a frame is left out.
|
|
19
|
+
* "eps" is vector PostScript: `size.width` becomes points (72 per inch).
|
|
11
20
|
*/
|
|
12
|
-
export type DownloadFormat =
|
|
21
|
+
export type DownloadFormat =
|
|
22
|
+
| "png"
|
|
23
|
+
| "jpg"
|
|
24
|
+
| "webp"
|
|
25
|
+
| "bmp"
|
|
26
|
+
| "gif"
|
|
27
|
+
| "ico"
|
|
28
|
+
| "svg"
|
|
29
|
+
| "pdf"
|
|
30
|
+
| "eps";
|
|
13
31
|
|
|
14
32
|
export interface DownloadFormatInfo {
|
|
15
33
|
mimeType: string;
|
|
16
34
|
extension: string;
|
|
17
35
|
/** No pixel size: the file name states none. */
|
|
18
36
|
vector: boolean;
|
|
37
|
+
/** The pixel sizes one file holds at once (ICO); its file name states none. */
|
|
38
|
+
sizes?: readonly number[];
|
|
19
39
|
}
|
|
20
40
|
|
|
21
41
|
/**
|
|
22
42
|
* Every download format with its MIME type and file extension. Each is made
|
|
23
43
|
* by one branch of downloadQRCode and getQRCodeDataUrl: PNG and JPG by the
|
|
24
44
|
* canvas, WebP by canvasToWebP (the canvas, or the built-in lossless
|
|
25
|
-
* encoder),
|
|
45
|
+
* encoder), BMP by canvasToBMP and GIF by canvasToGIF (the built-in encoders:
|
|
46
|
+
* no browser writes either),
|
|
47
|
+
* ICO by canvasesToICO (a PNG of each size inside the built-in ICO writer),
|
|
48
|
+
* SVG from the markup, PDF with jspdf, EPS by getQRAsEPS. A new
|
|
26
49
|
* format needs an entry here and a branch there.
|
|
27
50
|
*/
|
|
28
51
|
export const DOWNLOAD_FORMATS: Record<DownloadFormat, DownloadFormatInfo> = {
|
|
29
52
|
png: { mimeType: "image/png", extension: "png", vector: false },
|
|
30
53
|
jpg: { mimeType: "image/jpeg", extension: "jpg", vector: false },
|
|
31
54
|
webp: { mimeType: "image/webp", extension: "webp", vector: false },
|
|
55
|
+
bmp: { mimeType: "image/bmp", extension: "bmp", vector: false },
|
|
56
|
+
gif: { mimeType: GIF_MIME, extension: "gif", vector: false },
|
|
57
|
+
ico: {
|
|
58
|
+
mimeType: ICO_MIME,
|
|
59
|
+
extension: "ico",
|
|
60
|
+
vector: false,
|
|
61
|
+
sizes: ICO_SIZES,
|
|
62
|
+
},
|
|
32
63
|
svg: { mimeType: "image/svg+xml", extension: "svg", vector: true },
|
|
33
64
|
// A PDF download holds the PNG, so it's named after its pixel size.
|
|
34
65
|
pdf: { mimeType: "application/pdf", extension: "pdf", vector: false },
|
|
@@ -136,18 +167,19 @@ const getMimeType = (format: DownloadFormat): string =>
|
|
|
136
167
|
(DOWNLOAD_FORMATS[format] ?? DOWNLOAD_FORMATS.png).mimeType;
|
|
137
168
|
|
|
138
169
|
/**
|
|
139
|
-
* The default file name of a download: for PNG, JPG and
|
|
170
|
+
* The default file name of a download: for PNG, JPG, WebP, GIF and BMP (and the image
|
|
140
171
|
* a PDF holds) the exact pixel size of what is saved, which a frame makes
|
|
141
172
|
* bigger than the code (a 400 px code in a bottom banner is 496 × 568);
|
|
142
|
-
* SVG and EPS have no pixel size and name none
|
|
173
|
+
* SVG and EPS have no pixel size and name none, and nor does an ICO, which
|
|
174
|
+
* holds several.
|
|
143
175
|
*/
|
|
144
176
|
export function getDownloadFilename(
|
|
145
177
|
format: DownloadFormat,
|
|
146
178
|
size: DownloadSize,
|
|
147
179
|
frame?: QRProps["frame"]
|
|
148
180
|
): string {
|
|
149
|
-
const { extension, vector } = DOWNLOAD_FORMATS[format];
|
|
150
|
-
if (vector) {
|
|
181
|
+
const { extension, vector, sizes } = DOWNLOAD_FORMATS[format];
|
|
182
|
+
if (vector || sizes) {
|
|
151
183
|
return `qr-code.${extension}`;
|
|
152
184
|
}
|
|
153
185
|
// The canvas size getQRAsCanvas and getQRAsPDF draw on
|
|
@@ -177,6 +209,73 @@ export async function getQRAsWebP(
|
|
|
177
209
|
}
|
|
178
210
|
}
|
|
179
211
|
|
|
212
|
+
/**
|
|
213
|
+
* The code as a 24-bit BMP image (plus its frame, if any). A transparent
|
|
214
|
+
* background comes out white. Every browser gets it from QRdx's own encoder.
|
|
215
|
+
*/
|
|
216
|
+
export async function getQRAsBMP(qrProps: QRProps): Promise<Blob> {
|
|
217
|
+
const canvas = (await getQRAsCanvas(
|
|
218
|
+
qrProps,
|
|
219
|
+
"image/png",
|
|
220
|
+
true
|
|
221
|
+
)) as HTMLCanvasElement;
|
|
222
|
+
try {
|
|
223
|
+
return canvasToBMP(canvas);
|
|
224
|
+
} finally {
|
|
225
|
+
canvas.remove();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The code as a GIF image (plus its frame, if any), with a transparent
|
|
231
|
+
* background kept as GIF's one transparent color. A design that needs more
|
|
232
|
+
* than 256 colors is reduced to a palette, and refused with a GIFScanError
|
|
233
|
+
* when the reduced image would no longer scan. Every browser gets it from
|
|
234
|
+
* QRdx's own encoder.
|
|
235
|
+
*/
|
|
236
|
+
export async function getQRAsGIF(qrProps: QRProps): Promise<Blob> {
|
|
237
|
+
const canvas = (await getQRAsCanvas(
|
|
238
|
+
qrProps,
|
|
239
|
+
"image/png",
|
|
240
|
+
true
|
|
241
|
+
)) as HTMLCanvasElement;
|
|
242
|
+
try {
|
|
243
|
+
return await canvasToGIF(canvas, qrProps.value);
|
|
244
|
+
} finally {
|
|
245
|
+
canvas.remove();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The code as an ICO favicon holding it at each of `sizes` (16, 32, 48 and 256
|
|
251
|
+
* px by default), each an embedded PNG that keeps a transparent background.
|
|
252
|
+
* The size of `qrProps` doesn't apply, and a frame is left out: the
|
|
253
|
+
* images are square and no taller than 256 px. Every browser gets it from
|
|
254
|
+
* QRdx's own writer. Small sizes are for icons, not for scanning.
|
|
255
|
+
*/
|
|
256
|
+
export async function getQRAsICO(
|
|
257
|
+
qrProps: QRProps,
|
|
258
|
+
sizes: readonly number[] = ICO_SIZES
|
|
259
|
+
): Promise<Blob> {
|
|
260
|
+
const canvases: HTMLCanvasElement[] = [];
|
|
261
|
+
try {
|
|
262
|
+
for (const size of sizes) {
|
|
263
|
+
canvases.push(
|
|
264
|
+
(await getQRAsCanvas(
|
|
265
|
+
withQRSize({ ...qrProps, frame: undefined }, size),
|
|
266
|
+
"image/png",
|
|
267
|
+
true
|
|
268
|
+
)) as HTMLCanvasElement
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
return canvasesToICO(canvases);
|
|
272
|
+
} finally {
|
|
273
|
+
for (const canvas of canvases) {
|
|
274
|
+
canvas.remove();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
180
279
|
// One CSS pixel = one PostScript point (72 per inch).
|
|
181
280
|
const MM_PER_POINT = 25.4 / 72;
|
|
182
281
|
|
|
@@ -326,6 +425,15 @@ export async function downloadQRCode(
|
|
|
326
425
|
} else if (format === "webp") {
|
|
327
426
|
const webp = await getQRAsWebP(propsWithSize, { quality });
|
|
328
427
|
downloadFile(await blobToDataUrl(webp), finalFilename);
|
|
428
|
+
} else if (format === "bmp") {
|
|
429
|
+
const bmp = await getQRAsBMP(propsWithSize);
|
|
430
|
+
downloadFile(await blobToDataUrl(bmp), finalFilename);
|
|
431
|
+
} else if (format === "gif") {
|
|
432
|
+
const gif = await getQRAsGIF(propsWithSize);
|
|
433
|
+
downloadFile(await blobToDataUrl(gif), finalFilename);
|
|
434
|
+
} else if (format === "ico") {
|
|
435
|
+
const ico = await getQRAsICO(propsWithSize);
|
|
436
|
+
downloadFile(await blobToDataUrl(ico), finalFilename);
|
|
329
437
|
} else {
|
|
330
438
|
// Download as PNG or JPG
|
|
331
439
|
const mimeType = getMimeType(format);
|
|
@@ -376,6 +484,18 @@ export async function getQRCodeDataUrl(
|
|
|
376
484
|
return await blobToDataUrl(await getQRAsWebP(propsWithSize, options));
|
|
377
485
|
}
|
|
378
486
|
|
|
487
|
+
if (format === "bmp") {
|
|
488
|
+
return await blobToDataUrl(await getQRAsBMP(propsWithSize));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (format === "gif") {
|
|
492
|
+
return await blobToDataUrl(await getQRAsGIF(propsWithSize));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (format === "ico") {
|
|
496
|
+
return await blobToDataUrl(await getQRAsICO(propsWithSize));
|
|
497
|
+
}
|
|
498
|
+
|
|
379
499
|
const mimeType = getMimeType(format);
|
|
380
500
|
const result = await getQRAsCanvas(propsWithSize, mimeType);
|
|
381
501
|
|
package/src/element.ts
CHANGED
|
@@ -37,9 +37,15 @@ export interface QRdxCodeProperties {
|
|
|
37
37
|
moduleScale?: QRProps["moduleScale"];
|
|
38
38
|
autoLevel?: QRProps["autoLevel"];
|
|
39
39
|
shape?: QRProps["shape"];
|
|
40
|
+
eyeGradient?: QRProps["eyeGradient"];
|
|
41
|
+
bgRadius?: QRProps["bgRadius"];
|
|
42
|
+
backdrop?: QRProps["backdrop"];
|
|
40
43
|
frame?: QRProps["frame"];
|
|
41
44
|
imageSettings?: QRProps["imageSettings"];
|
|
42
45
|
eyeColors?: QRProps["eyeColors"];
|
|
46
|
+
eyeShapes?: QRProps["eyeShapes"];
|
|
47
|
+
halo?: QRProps["halo"];
|
|
48
|
+
shadow?: QRProps["shadow"];
|
|
43
49
|
art?: QRProps["art"];
|
|
44
50
|
customTemplate?: QRProps["customTemplate"];
|
|
45
51
|
customProps?: QRProps["customProps"];
|
|
@@ -66,6 +72,9 @@ export interface QRdxCodeAttributes {
|
|
|
66
72
|
"module-scale"?: number | string;
|
|
67
73
|
"auto-level"?: boolean | string;
|
|
68
74
|
shape?: string;
|
|
75
|
+
"eye-gradient"?: string;
|
|
76
|
+
"bg-radius"?: number | string;
|
|
77
|
+
backdrop?: string;
|
|
69
78
|
label?: string;
|
|
70
79
|
/** Options as JSON, for markup without script */
|
|
71
80
|
props?: string;
|
|
@@ -105,6 +114,9 @@ const ATTRIBUTES: Record<string, [OptionKey, AttributeKind]> = {
|
|
|
105
114
|
"module-scale": ["moduleScale", "number"],
|
|
106
115
|
"auto-level": ["autoLevel", "boolean"],
|
|
107
116
|
shape: ["shape", "string"],
|
|
117
|
+
"eye-gradient": ["eyeGradient", "string"],
|
|
118
|
+
"bg-radius": ["bgRadius", "number"],
|
|
119
|
+
backdrop: ["backdrop", "string"],
|
|
108
120
|
};
|
|
109
121
|
|
|
110
122
|
/** Options that are properties of the element. */
|
|
@@ -113,6 +125,9 @@ const OPTION_KEYS: readonly OptionKey[] = [
|
|
|
113
125
|
"frame",
|
|
114
126
|
"imageSettings",
|
|
115
127
|
"eyeColors",
|
|
128
|
+
"eyeShapes",
|
|
129
|
+
"halo",
|
|
130
|
+
"shadow",
|
|
116
131
|
"art",
|
|
117
132
|
"customTemplate",
|
|
118
133
|
"customProps",
|
|
@@ -357,7 +372,7 @@ export class QRdxCodeElement extends BaseElement {
|
|
|
357
372
|
return renderToString(createQRCodeTree(this.#requireOptions()));
|
|
358
373
|
}
|
|
359
374
|
|
|
360
|
-
/** The code as a data URL: "png" (default), "jpg", "webp", "svg", "pdf" or "eps". */
|
|
375
|
+
/** The code as a data URL: "png" (default), "jpg", "webp", "bmp", "ico", "gif", "svg", "pdf" or "eps". */
|
|
361
376
|
async toDataURL(
|
|
362
377
|
format: DownloadFormat = "png",
|
|
363
378
|
options: QRCodeExportOptions = {}
|
package/src/engine.ts
CHANGED
|
@@ -25,6 +25,9 @@ export {
|
|
|
25
25
|
excavationSchema,
|
|
26
26
|
eyeColorOverrideSchema,
|
|
27
27
|
eyeColorsSchema,
|
|
28
|
+
eyeGradientSpanSchema,
|
|
29
|
+
eyeShapeOverrideSchema,
|
|
30
|
+
eyeShapesSchema,
|
|
28
31
|
frameSchema,
|
|
29
32
|
frameSpecColorSchema,
|
|
30
33
|
frameSpecLabelSchema,
|
|
@@ -34,6 +37,7 @@ export {
|
|
|
34
37
|
frameStyleSchema,
|
|
35
38
|
getFrameSpecIssues,
|
|
36
39
|
gradientStopSchema,
|
|
40
|
+
haloSchema,
|
|
37
41
|
imageFitSchema,
|
|
38
42
|
imagePaintSchema,
|
|
39
43
|
imagePositionSchema,
|
|
@@ -52,6 +56,7 @@ export {
|
|
|
52
56
|
qrShapeSchema,
|
|
53
57
|
qrSilhouetteSchema,
|
|
54
58
|
radialGradientSchema,
|
|
59
|
+
shadowSchema,
|
|
55
60
|
solidColorSchema,
|
|
56
61
|
templateConfigSchema,
|
|
57
62
|
templateDefinitionBaseSchema,
|
|
@@ -73,6 +78,7 @@ export {
|
|
|
73
78
|
type QRArtRenderOptions,
|
|
74
79
|
renderQRArt,
|
|
75
80
|
} from "./art";
|
|
81
|
+
export * from "./bmp";
|
|
76
82
|
export { clampModuleScale, MODULE_SCALE_FLOOR } from "./body-patterns";
|
|
77
83
|
export {
|
|
78
84
|
type CodewordMap,
|
|
@@ -95,6 +101,7 @@ export {
|
|
|
95
101
|
} from "./eps";
|
|
96
102
|
export { getQRAsCanvas, getQRAsSVGDataUri } from "./export";
|
|
97
103
|
export {
|
|
104
|
+
createFrameTree,
|
|
98
105
|
FRAME_FONT_FAMILY,
|
|
99
106
|
FRAME_GAP_RATIO,
|
|
100
107
|
FRAME_LABEL_ATTRIBUTE,
|
|
@@ -105,6 +112,7 @@ export {
|
|
|
105
112
|
type FramePolygon,
|
|
106
113
|
type FrameRect,
|
|
107
114
|
type FrameShape,
|
|
115
|
+
type FrameTreeOptions,
|
|
108
116
|
frameLabels,
|
|
109
117
|
getFrameDimensions,
|
|
110
118
|
getFrameGapRatio,
|
|
@@ -156,7 +164,9 @@ export type {
|
|
|
156
164
|
OfficialFrameIndexEntry,
|
|
157
165
|
} from "./frames/official-types";
|
|
158
166
|
export { frameSpecHash } from "./frames/spec-hash";
|
|
167
|
+
export * from "./gif";
|
|
159
168
|
export { getLogoSizeLimit, getQRData } from "./helpers";
|
|
169
|
+
export * from "./ico";
|
|
160
170
|
export {
|
|
161
171
|
Fragment,
|
|
162
172
|
h,
|
|
@@ -182,6 +192,19 @@ export {
|
|
|
182
192
|
removeLogoBackdrop,
|
|
183
193
|
removeLogoBackground,
|
|
184
194
|
} from "./logo-cleanup";
|
|
195
|
+
export {
|
|
196
|
+
clampBgRadius,
|
|
197
|
+
colorAlpha,
|
|
198
|
+
eyeShapeOf,
|
|
199
|
+
getBgRadiusLimit,
|
|
200
|
+
getEyeStyleRisk,
|
|
201
|
+
getHaloRisk,
|
|
202
|
+
type HaloRisk,
|
|
203
|
+
isSeeThroughBackground,
|
|
204
|
+
resolveHalo,
|
|
205
|
+
resolveShadow,
|
|
206
|
+
weakestEyePattern,
|
|
207
|
+
} from "./looks";
|
|
185
208
|
export {
|
|
186
209
|
partMarker,
|
|
187
210
|
QR_EYE_ATTRIBUTE,
|
package/src/eps.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
collectGradientColors,
|
|
36
36
|
collectImageHrefs,
|
|
37
37
|
length,
|
|
38
|
+
lineStyleOf,
|
|
38
39
|
type PaintState,
|
|
39
40
|
rasterizeImage,
|
|
40
41
|
SvgPainter,
|
|
@@ -434,8 +435,14 @@ class EpsPainter extends SvgPainter {
|
|
|
434
435
|
this.out.push(`${this.color(fill)} ${path} ${fillOp}`);
|
|
435
436
|
}
|
|
436
437
|
if (stroke) {
|
|
438
|
+
const draw = `${this.color(stroke)} ${fmt(state.strokeWidth * matrixScale(state.matrix))} w ${path} s`;
|
|
439
|
+
// Round joins and caps where the SVG asks for them (the halo's rim),
|
|
440
|
+
// kept to this stroke
|
|
441
|
+
const { join, cap } = lineStyleOf(state);
|
|
437
442
|
this.out.push(
|
|
438
|
-
|
|
443
|
+
join || cap
|
|
444
|
+
? `gsave ${join} setlinejoin ${cap} setlinecap ${draw} grestore`
|
|
445
|
+
: draw
|
|
439
446
|
);
|
|
440
447
|
}
|
|
441
448
|
}
|
package/src/export.ts
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
// score and qrdx/node's PNG all start here; none of it needs React.
|
|
5
5
|
|
|
6
6
|
import type { QRProps } from "../types";
|
|
7
|
+
import { canvasToBMP } from "./bmp";
|
|
7
8
|
import { DEFAULT_SIZE } from "./constants";
|
|
8
9
|
import { getFrameDimensions } from "./frame";
|
|
10
|
+
import { canvasToGIF, GIF_MIME } from "./gif";
|
|
11
|
+
import { canvasToICO, ICO_MIME } from "./ico";
|
|
9
12
|
import { toSVGString } from "./svg";
|
|
10
13
|
import { blobToDataUrl, canvasToWebP } from "./webp";
|
|
11
14
|
|
|
@@ -188,6 +191,25 @@ export async function getQRAsCanvas(
|
|
|
188
191
|
.then(blobToDataUrl)
|
|
189
192
|
.then(resolve, reject)
|
|
190
193
|
.finally(() => canvas.remove());
|
|
194
|
+
} else if (type === "image/bmp") {
|
|
195
|
+
// toDataURL would hand back a PNG: no browser encodes BMP.
|
|
196
|
+
blobToDataUrl(canvasToBMP(canvas))
|
|
197
|
+
.then(resolve, reject)
|
|
198
|
+
.finally(() => canvas.remove());
|
|
199
|
+
} else if (type === GIF_MIME) {
|
|
200
|
+
// toDataURL would hand back a PNG: no browser encodes GIF. A design
|
|
201
|
+
// that needs more than 256 colors and would stop scanning is refused.
|
|
202
|
+
canvasToGIF(canvas, props.value)
|
|
203
|
+
.then(blobToDataUrl)
|
|
204
|
+
.then(resolve, reject)
|
|
205
|
+
.finally(() => canvas.remove());
|
|
206
|
+
} else if (type === ICO_MIME || type === "image/x-icon") {
|
|
207
|
+
// toDataURL would hand back a PNG: no browser encodes ICO. This is
|
|
208
|
+
// an ICO of the one canvas (at most 256 px); getQRAsICO makes the
|
|
209
|
+
// favicon with several sizes.
|
|
210
|
+
blobToDataUrl(canvasToICO(canvas))
|
|
211
|
+
.then(resolve, reject)
|
|
212
|
+
.finally(() => canvas.remove());
|
|
191
213
|
} else {
|
|
192
214
|
const dataUrl = canvas.toDataURL(type, 1.0);
|
|
193
215
|
canvas.remove();
|
package/src/frame.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import type { ColorConfig } from "../types";
|
|
|
4
4
|
import { DEFAULT_FRAME_TEXT, FRAME_TEXT_MAX_LENGTH } from "../types/constants";
|
|
5
5
|
import type { AnyQRFrame } from "../types/frame-spec";
|
|
6
6
|
import { CUSTOM_FRAME_STYLE } from "../types/frame-spec-rules";
|
|
7
|
+
import { DEFAULT_SIZE } from "./constants";
|
|
7
8
|
import { getCustomFrameLayout, getFrameSpecGapRatio } from "./frame-spec";
|
|
8
9
|
import { frameSpecOf, getBuiltInFrameLayout } from "./frames/builtin";
|
|
9
10
|
import { cloneElement, type QRNode } from "./jsx/runtime";
|
|
@@ -317,6 +318,56 @@ export function wrapWithFrame(
|
|
|
317
318
|
);
|
|
318
319
|
}
|
|
319
320
|
|
|
321
|
+
/** What `createFrameTree` draws: a frame with no code in it. */
|
|
322
|
+
export interface FrameTreeOptions {
|
|
323
|
+
frame: AnyQRFrame;
|
|
324
|
+
/** The code the frame is laid out around, in pixels (default 128) */
|
|
325
|
+
size?: number;
|
|
326
|
+
/** The code's background, for frames that take their plate from it */
|
|
327
|
+
bgColor?: ColorConfig;
|
|
328
|
+
/**
|
|
329
|
+
* Drawn where the code would be, placed as the code is (a nested <svg>
|
|
330
|
+
* given the code's offset and a `size × size` box). Left out, the slot is
|
|
331
|
+
* empty.
|
|
332
|
+
*/
|
|
333
|
+
slot?: QRNode;
|
|
334
|
+
/** Attributes for the outer <svg> (React's names: className, style…) */
|
|
335
|
+
svgProps?: Record<string, unknown>;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* A frame on its own: its artwork and labels around the slot a code of
|
|
340
|
+
* `size` pixels would fill (getFrameLayout's qrX, qrY and qrSize), with no
|
|
341
|
+
* code drawn, for showing what a frame is without a code (a frame gallery).
|
|
342
|
+
* The markup is the framed code's, with `slot` (or an empty <svg>) in the
|
|
343
|
+
* code's place. Without an active frame, the slot alone.
|
|
344
|
+
*/
|
|
345
|
+
export function createFrameTree(options: FrameTreeOptions): QRNode {
|
|
346
|
+
const { frame, size = DEFAULT_SIZE, bgColor, slot, svgProps } = options;
|
|
347
|
+
const content = slot ?? (
|
|
348
|
+
<svg
|
|
349
|
+
height={size}
|
|
350
|
+
viewBox={`0 0 ${size} ${size}`}
|
|
351
|
+
width={size}
|
|
352
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
353
|
+
/>
|
|
354
|
+
);
|
|
355
|
+
if (!isFrameActive(frame)) {
|
|
356
|
+
return (
|
|
357
|
+
<svg
|
|
358
|
+
height={size}
|
|
359
|
+
viewBox={`0 0 ${size} ${size}`}
|
|
360
|
+
width={size}
|
|
361
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
362
|
+
{...svgProps}
|
|
363
|
+
>
|
|
364
|
+
{cloneElement(content, { x: 0, y: 0, width: size, height: size })}
|
|
365
|
+
</svg>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
return wrapWithFrame(content, { size, frame, bgColor, svgProps });
|
|
369
|
+
}
|
|
370
|
+
|
|
320
371
|
/** Every label of a layout: the main one first, then the extra ones. */
|
|
321
372
|
export function frameLabels(layout: FrameLayout): FrameLabel[] {
|
|
322
373
|
return [
|