@liquid-js/qr-code-styling 5.4.1 → 5.4.3
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/lib/border-plugin.js +1 -1
- package/lib/border-plugin.js.map +1 -1
- package/lib/plugins/border.d.ts +0 -1
- package/lib/qr-code-styling-node.js +2 -2
- package/lib/qr-code-styling-node.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/package.json +1 -1
package/lib/border-plugin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{extendSVG as t,numToAttr as e,svgPath as i}from"./plugin-utils.js";import{c as o}from"./color-dXYWdVDW.js";var s,r=s||={};r.top="top",r.bottom="bottom",r.left="left",r.right="right";export default class{pluginOptions;idSuffix;constructor(t,e=Math.random().toFixed(10).substring(2)){this.pluginOptions=t,this.idSuffix=e}postProcess(r,n,a){var{document:p}=n
|
|
1
|
+
import{extendSVG as t,numToAttr as e,svgPath as i}from"./plugin-utils.js";import{c as o}from"./color-dXYWdVDW.js";var s,r=s||={};r.top="top",r.bottom="bottom",r.left="left",r.right="right";export default class{pluginOptions;idSuffix;constructor(t,e=Math.random().toFixed(10).substring(2)){this.pluginOptions=t,this.idSuffix=e}postProcess(r,n,a){var{document:p}=n,$=this.pluginOptions.proportional?n.size:1,h=this.pluginOptions.size*$,l=t(r,h+(this.pluginOptions.margin||0)*$);if(l){h=Math.abs(h);var d=(l.left+l.right)/2,u=(l.top+l.bottom)/2,g=n.size/2*(1-(this.pluginOptions.round||0)),f=Math.min(l.right-l.left-2*h,l.bottom-l.top-2*h)/2-g+h/2,w=this.pluginOptions.round?f:0,c=this.pluginOptions.round?g:g+f;(l=p.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("width",e(2*(c+w))),l.setAttribute("height",e(2*(c+w))),l.setAttribute("x",e(d-c-w)),l.setAttribute("y",e(u-c-w)),l.setAttribute("rx",e(w)),l.setAttribute("fill","none"),l.setAttribute("stroke-width",e(h)),this.pluginOptions.dasharray&&l.setAttribute("stroke-dasharray",this.pluginOptions.dasharray),(n=o({options:this.pluginOptions.gradient,color:this.pluginOptions.color,additionalRotation:0,x:d-c-w,y:u-c-w,height:2*w,width:2*w,name:`border-color-${this.idSuffix}`,dotSize:n.dotsOptions.size,document:n.document}))?(n.gradient&&((a=Array.from(r.childNodes).find(t=>"DEFS"==t.tagName.toUpperCase()))||(a=p.createElementNS("http://www.w3.org/2000/svg","defs"),r.appendChild(a)),a.appendChild(n.gradient)),l.setAttribute("stroke",n.value),n.opacity<1&&l.setAttribute("stroke-opacity",n.opacity.toFixed(7))):a.dots&&(l.setAttribute("stroke",a.dots.value),a.dots.opacity<1&&l.setAttribute("stroke-opacity",a.dots.opacity.toFixed(7))),r.appendChild(l),[s.left,s.top,s.right,s.bottom].forEach(t=>{var o=this.pluginOptions.text,n=o?.[t];if(n){let a=Array.from(r.childNodes).find(t=>"DEFS"==t.tagName.toUpperCase());a||(a=p.createElementNS("http://www.w3.org/2000/svg","defs"),r.appendChild(a));let h=p.createElementNS("http://www.w3.org/2000/svg","path"),l=(n.size||o.size||1)*$;switch(w=this.pluginOptions.round?f-l/3:0,c=this.pluginOptions.round?g:g+(f-l/3),t){case s.top:h.setAttribute("d",i`M ${d} ${u+w+c} h ${-c} a ${w} ${w} 0 0 1 ${-w} ${-w} v ${-2*c} a ${w} ${w} 0 0 1 ${w} ${-w} h ${2*c} a ${w} ${w} 0 0 1 ${w} ${w} v ${2*c} a ${w} ${w} 0 0 1 ${-w} ${w} h ${-c}`);break;case s.bottom:this.pluginOptions.round?w+=2*l/3:c+=2*l/3,h.setAttribute("d",i`M ${d} ${u-w-c} h ${-c} a ${w} ${w} 0 0 0 ${-w} ${w} v ${2*c} a ${w} ${w} 0 0 0 ${w} ${w} h ${2*c} a ${w} ${w} 0 0 0 ${w} ${-w} v ${-2*c} a ${w} ${w} 0 0 0 ${-w} ${-w} h ${-c}`);break;case s.left:h.setAttribute("d",i`M ${d+w+c} ${u} v ${c} a ${w} ${w} 0 0 1 ${-w} ${w} h ${-2*c} a ${w} ${w} 0 0 1 ${-w} ${-w} v ${-2*c} a ${w} ${w} 0 0 1 ${w} ${-w} h ${2*c} a ${w} ${w} 0 0 1 ${w} ${w} v ${c}`);break;case s.right:h.setAttribute("d",i`M ${d-w-c} ${u} v ${-c} a ${w} ${w} 0 0 1 ${w} ${-w} h ${2*c} a ${w} ${w} 0 0 1 ${w} ${w} v ${2*c} a ${w} ${w} 0 0 1 ${-w} ${w} h ${-2*c} a ${w} ${w} 0 0 1 ${-w} ${-w} v ${-c}`)}t=`border-text-${t}-${this.idSuffix}`,h.setAttribute("id",t),h.setAttribute("fill","none");let b=p.createElementNS("http://www.w3.org/2000/svg","tspan");b.setAttribute("font-family",n.font||o.font||"sans-serif"),b.setAttribute("fill",n.color||o.color||"#000"),b.setAttribute("font-weight",e(n.fontWeight||o.fontWeight||"normal")),b.setAttribute("font-style",n.fontStyle||o.fontStyle||"normal"),b.setAttribute("font-size",e(l)),b.textContent=n.content,(o=p.createElementNS("http://www.w3.org/2000/svg","textPath")).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+t),o.setAttribute("startOffset","50%"),o.setAttribute("text-anchor","middle"),o.appendChild(b),(n=p.createElementNS("http://www.w3.org/2000/svg","text")).appendChild(o),a.appendChild(h),r.appendChild(n)}}),this.pluginOptions.fontFaces&&((a=Array.from(r.childNodes).find(t=>"DEFS"==t.tagName.toUpperCase()))||(a=p.createElementNS("http://www.w3.org/2000/svg","defs"),r.appendChild(a)),(l=p.createElementNS("http://www.w3.org/2000/svg","style")).textContent=this.pluginOptions.fontFaces,a.appendChild(l))}}}
|
|
2
2
|
//# sourceMappingURL=border-plugin.js.map
|
package/lib/border-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"border-plugin.js","sources":["../src/plugins/border.ts"],"sourcesContent":["import { ColorElementValue, createColor } from '../utils/color.js'\r\nimport { Gradient } from '../utils/gradient.js'\r\nimport { Options, Plugin } from '../utils/options.js'\r\nimport { extendSVG, numToAttr, svgPath } from './utils.js'\r\n\r\nenum TextPosition {\r\n top = 'top',\r\n bottom = 'bottom',\r\n left = 'left',\r\n right = 'right'\r\n}\r\n\r\nexport interface TextConfig {\r\n font?: string\r\n color?: string\r\n gradient?: Gradient\r\n size?: number\r\n fontWeight?: 'normal' | 'bold' | number\r\n fontStyle?: 'normal' | 'italic' | 'oblique'\r\n}\r\n\r\nexport interface BorderPluginOptions {\r\n /** Border roundnes, from 0 (square) to 1 (circle) */\r\n round?: number\r\n size: number\r\n color?: string\r\n gradient?: Gradient\r\n dasharray?: string\r\n margin?: number\r\n /**\r\n * If true, all dimensions are proportional to the code size,\r\n * i.e. `size: 0.1` means the border thickness is 1/10 of the QR code size\r\n *\r\n * This is useful to keep the border visually consistent regardless of the amount of data\r\n *\r\n * Note: if using dasharray, use percentage values to maintain consistency\r\n */\r\n proportional?: boolean\r\n text?: TextConfig & {\r\n [key in TextPosition]?: TextConfig & {\r\n content: string\r\n }\r\n }\r\n /**\r\n * A string of embedded CSS \\@font-face rules\r\n *\r\n * @deprecated Use @liquid-js/qr-code-styling/font-faces-plugin\r\n */\r\n fontFaces?: string\r\n}\r\n\r\nexport default class BorderPlugin implements Plugin {\r\n\r\n constructor(\r\n private readonly pluginOptions: BorderPluginOptions,\r\n /** @ignore Create unique id for SVG elements to prevent naming collisions; specify your own if neccesary e.g. for testing */\r\n private readonly idSuffix = Math.random().toFixed(10).substring(2)\r\n ) { }\r\n\r\n postProcess(svg: SVGSVGElement, options: Options, colors: {\r\n dots?: ColorElementValue\r\n background?: ColorElementValue\r\n }) {\r\n const { document } = options\r\n const sizeFactor = this.pluginOptions.proportional ? options.size : 1\r\n\r\n const margin = (this.pluginOptions.margin || 0) * sizeFactor\r\n let thickness = (this.pluginOptions.size) * sizeFactor\r\n const drawArea = extendSVG(svg, thickness + margin)\r\n if (!drawArea)\r\n return\r\n\r\n thickness = Math.abs(thickness)\r\n\r\n const cx = (drawArea.left + drawArea.right) / 2\r\n const cy = (drawArea.top + drawArea.bottom) / 2\r\n const lineSize = options.size / 2 * (1 - (this.pluginOptions.round || 0))\r\n const r = (Math.min(drawArea.right - drawArea.left - 2 * thickness, drawArea.bottom - drawArea.top - 2 * thickness) / 2) - lineSize + thickness / 2\r\n\r\n let pathR = this.pluginOptions.round ? r : 0\r\n let pathL = this.pluginOptions.round ? lineSize : lineSize + r\r\n\r\n const borderEl = document.createElementNS('http://www.w3.org/2000/svg', 'rect')\r\n borderEl.setAttribute('width', numToAttr((pathL + pathR) * 2))\r\n borderEl.setAttribute('height', numToAttr((pathL + pathR) * 2))\r\n borderEl.setAttribute('x', numToAttr(cx - pathL - pathR))\r\n borderEl.setAttribute('y', numToAttr(cy - pathL - pathR))\r\n borderEl.setAttribute('rx', numToAttr(pathR))\r\n borderEl.setAttribute('fill', 'none')\r\n borderEl.setAttribute('stroke-width', numToAttr(thickness))\r\n if (this.pluginOptions.dasharray) {\r\n borderEl.setAttribute('stroke-dasharray', this.pluginOptions.dasharray)\r\n }\r\n\r\n const value = createColor({\r\n options: this.pluginOptions.gradient,\r\n color: this.pluginOptions.color,\r\n additionalRotation: 0,\r\n x: cx - pathL - pathR,\r\n y: cy - pathL - pathR,\r\n height: 2 * pathR,\r\n width: 2 * pathR,\r\n name: `border-color-${this.idSuffix}`,\r\n dotSize: options.dotsOptions.size,\r\n document: options.document\r\n })\r\n\r\n if (value) {\r\n if (value.gradient) {\r\n let defs = Array.from(svg.childNodes).find(v => (v as HTMLElement).tagName.toUpperCase() == 'DEFS')\r\n if (!defs) {\r\n defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')\r\n svg.appendChild(defs)\r\n }\r\n defs.appendChild(value.gradient)\r\n }\r\n borderEl.setAttribute('stroke', value.value)\r\n\r\n if (value.opacity < 1) borderEl.setAttribute('stroke-opacity', value.opacity.toFixed(7))\r\n } else if (colors.dots) {\r\n borderEl.setAttribute('stroke', colors.dots.value)\r\n\r\n if (colors.dots.opacity < 1) borderEl.setAttribute('stroke-opacity', colors.dots.opacity.toFixed(7))\r\n }\r\n\r\n svg.appendChild(borderEl)\r\n\r\n const textColor = createColor({\r\n options: this.pluginOptions.text?.gradient,\r\n color: this.pluginOptions.text?.color,\r\n additionalRotation: 0,\r\n x: cx - pathL - pathR,\r\n y: cy - pathL - pathR,\r\n height: 2 * pathR,\r\n width: 2 * pathR,\r\n name: `border-text-color-${this.idSuffix}`,\r\n dotSize: options.dotsOptions.size,\r\n document: options.document\r\n });\r\n\r\n [TextPosition.left, TextPosition.top, TextPosition.right, TextPosition.bottom].forEach(postion => {\r\n const textCfg = this.pluginOptions.text\r\n const config = textCfg?.[postion]\r\n if (config) {\r\n let defs = Array.from(svg.childNodes).find(v => (v as HTMLElement).tagName.toUpperCase() == 'DEFS')\r\n if (!defs) {\r\n defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')\r\n svg.appendChild(defs)\r\n }\r\n const element = document.createElementNS('http://www.w3.org/2000/svg', 'path')\r\n const size = (config.size || textCfg.size || 1) * sizeFactor\r\n pathR = this.pluginOptions.round ? r - size / 3 : 0\r\n pathL = this.pluginOptions.round ? lineSize : lineSize + (r - size / 3)\r\n switch (postion) {\r\n case TextPosition.top:\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx} ${cy + pathR + pathL}\r\n h ${-pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${-pathR}\r\n v ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${-pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${pathR}\r\n v ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${pathR}\r\n h ${-pathL}`\r\n )\r\n break\r\n case TextPosition.bottom:\r\n if (this.pluginOptions.round)\r\n pathR += size * 2 / 3\r\n else\r\n pathL += size * 2 / 3\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx} ${cy - pathR - pathL}\r\n h ${-pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${-pathR} ${pathR}\r\n v ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${pathR} ${pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${pathR} ${-pathR}\r\n v ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${-pathR} ${-pathR}\r\n h ${-pathL}`\r\n )\r\n break\r\n case TextPosition.left:\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx + pathR + pathL} ${cy}\r\n v ${pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${pathR}\r\n h ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${-pathR}\r\n v ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${-pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${pathR}\r\n v ${pathL}`\r\n )\r\n break\r\n case TextPosition.right:\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx - pathR - pathL} ${cy}\r\n v ${-pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${-pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${pathR}\r\n v ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${pathR}\r\n h ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${-pathR}\r\n v ${-pathL}`\r\n )\r\n break\r\n }\r\n const id = `border-text-${postion}-${this.idSuffix}`\r\n element.setAttribute('id', id)\r\n element.setAttribute('fill', 'none')\r\n\r\n const span = document.createElementNS('http://www.w3.org/2000/svg', 'tspan')\r\n span.setAttribute('font-family', config.font || textCfg.font || 'sans-serif')\r\n span.setAttribute('font-weight', numToAttr(config.fontWeight || textCfg.fontWeight || 'normal'))\r\n span.setAttribute('font-style', config.fontStyle || textCfg.fontStyle || 'normal')\r\n span.setAttribute('font-size', numToAttr(size))\r\n span.textContent = config.content\r\n\r\n const color = createColor({\r\n options: config.gradient,\r\n color: config.color,\r\n additionalRotation: 0,\r\n x: cx - pathL - pathR,\r\n y: cy - pathL - pathR,\r\n height: 2 * pathR,\r\n width: 2 * pathR,\r\n name: `border-text-color-${this.idSuffix}-${postion}`,\r\n dotSize: options.dotsOptions.size,\r\n document: options.document\r\n }) || textColor\r\n\r\n if (color) {\r\n if (color.gradient)\r\n defs.appendChild(color.gradient)\r\n\r\n span.setAttribute('fill', color.value)\r\n\r\n if (color.opacity < 1) span.setAttribute('opacity', color.opacity.toFixed(7))\r\n } else if (colors.dots) {\r\n span.setAttribute('fill', colors.dots.value)\r\n\r\n if (colors.dots.opacity < 1) span.setAttribute('opacity', colors.dots.opacity.toFixed(7))\r\n }\r\n\r\n const textPath = document.createElementNS('http://www.w3.org/2000/svg', 'textPath')\r\n textPath.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + id)\r\n textPath.setAttribute('startOffset', '50%')\r\n textPath.setAttribute('text-anchor', 'middle')\r\n textPath.appendChild(span)\r\n\r\n const text = document.createElementNS('http://www.w3.org/2000/svg', 'text')\r\n text.appendChild(textPath)\r\n\r\n defs.appendChild(element)\r\n svg.appendChild(text)\r\n }\r\n })\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n if (this.pluginOptions.fontFaces) {\r\n let defs = Array.from(svg.childNodes).find(v => (v as HTMLElement).tagName.toUpperCase() == 'DEFS')\r\n if (!defs) {\r\n defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')\r\n svg.appendChild(defs)\r\n }\r\n const style = document.createElementNS('http://www.w3.org/2000/svg', 'style')\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n style.textContent = this.pluginOptions.fontFaces\r\n defs.appendChild(style)\r\n }\r\n }\r\n}\r\n"],"names":["extendSVG","numToAttr","TextPosition","createColor","k","y","top","bottom","left","right","pluginOptions","idSuffix","constructor","Math","random","toFixed","substring","this","postProcess","svg","options","colors","document","sizeFactor","proportional","size","thickness","drawArea","margin","abs","cx","cy","round","min","lineSize","pathR","r","pathL","createElementNS","setAttribute","borderEl","dasharray","value","gradient","color","additionalRotation","x","height","width","name","dotSize","dotsOptions","defs","Array","from","childNodes","find","v","tagName","toUpperCase","appendChild","opacity","dots","textColor","text","forEach","postion","textCfg","config","element","svgPath","id","span","font","fontWeight","fontStyle","textContent","content","textPath","setAttributeNS","fontFaces","style"],"mappings":"oBAKKA,eACDC,aACAC,MAAA,gCAEAC,MA0CU,sBAAA,IAAAC,EAAAC,EAAAD,IAAA,CAAA,EAAAC,EAAAC,IAAA,MAAAD,EAAAE,OAAA,SAAAF,EAAAG,KAAA,OAAAH,EAAAI,MAAA,6BAGWC,cAEAC,SAHrBC,WAAAA,CACqBF,EAEAC,EAAWE,KAAKC,SAASC,QAAQ,IAAIC,UAAU,IAF/CC,KAAAP,cAAAA,EAEAO,KAAAN,SAAAA,CAAiD,CAGtEO,WAAAA,CAAYC,EAAoBC,EAAkBC,GAI9C,IAAMC,SAAAA,KACNC,EAAgBN,KAAGP,cAAKc,aAA0BJ,EAAGK,OAGjDC,EAAaT,KAAKP,cAAce,KAAQF,EAC5CI,EAAc3B,EAAGmB,EAAaO,GAFlBT,KAAIP,cAAKkB,QAAoB,GAAKL,MAGzCI,EAAL,CAGAD,EAAYb,KAAKgB,IAAIH,GAErB,IAAAI,GAAQH,EAAInB,KAAamB,EAAGlB,OAAc,EAC1CsB,GAAQJ,EAAIrB,IAAYqB,EAAGpB,QAAe,IAC5Ba,UAAmB,GAAKH,KAAIP,cAAKsB,OAAmB,MAC3DnB,KAAIoB,IAAKN,EAAIlB,MAAckB,EAAGnB,KAAa,EAAIkB,EAAYC,EAAEpB,OAAeoB,QAAmBD,KAAiBQ,EAAYR,IAE/HS,EAAQlB,KAAKP,cAAcsB,MAAQI,EAAI,E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F,EAChBY,OAAQ,EAAIZ,EACZa,MAAO,EAAIb,EACXc,KAAM,qBAAqBhC,KAAKN,YAAYuD,IAC5ChB,QAAS9B,EAAQ+B,YAAY1B,KAC7BH,SAAUF,EAAQE,YAChByC,IAGEnB,EAAMD,UACNS,EAAKQ,YAAYhB,EAAMD,UAE3B6B,EAAKjC,aAAa,OAAQK,EAAMF,OAE5BE,EAAMiB,QAAU,GAAGW,EAAKjC,aAAa,UAAWK,EAAMiB,QAAQ9C,QAAQ,KACnEM,EAAOyC,OACdU,EAAKjC,aAAa,OAAQlB,EAAOyC,KAAKpB,OAElCrB,EAAOyC,KAAKD,QAAU,GAAGW,EAAKjC,aAAa,UAAWlB,EAAOyC,KAAKD,QAAQ9C,QAAQ,MAG1F+D,EAAcxD,EAAGgB,6CAAqD,aAC7DyC,eAAe,+BAAgC,aAAc,IAAMR,GAC5EO,EAASvC,aAAa,cAAe,OACrCuC,EAASvC,aAAa,cAAe,UACrCuC,EAASlB,YAAYY,IAErBR,EAAU1C,EAAGgB,6CAAqD,SAC7DsB,YAAYkB,GAEjB1B,EAAKQ,YAAYS,GACjBlD,EAAIyC,YAAYI,EA3HR,IAgIZ/C,KAAKP,cAAcsE,aACf5B,EAAOC,MAAMC,KAAKnC,EAAIoC,YAAYC,KAAKC,GAAiD,QAA3CA,EAAkBC,QAAQC,kBAEvEP,EAAO9B,EAASgB,gBAAgB,6BAA8B,QAC9DnB,EAAIyC,YAAYR,KAEpB6B,EAAW3D,EAAGgB,6CAAqD,UAE7DsC,YAAc3D,KAAKP,cAAcsE,UACvC5B,EAAKQ,YAAYqB,GAnNrB,CAPH"}
|
|
1
|
+
{"version":3,"file":"border-plugin.js","sources":["../src/plugins/border.ts"],"sourcesContent":["import { ColorElementValue, createColor } from '../utils/color.js'\r\nimport { Gradient } from '../utils/gradient.js'\r\nimport { Options, Plugin } from '../utils/options.js'\r\nimport { extendSVG, numToAttr, svgPath } from './utils.js'\r\n\r\nenum TextPosition {\r\n top = 'top',\r\n bottom = 'bottom',\r\n left = 'left',\r\n right = 'right'\r\n}\r\n\r\nexport interface TextConfig {\r\n font?: string\r\n color?: string\r\n size?: number\r\n fontWeight?: 'normal' | 'bold' | number\r\n fontStyle?: 'normal' | 'italic' | 'oblique'\r\n}\r\n\r\nexport interface BorderPluginOptions {\r\n /** Border roundnes, from 0 (square) to 1 (circle) */\r\n round?: number\r\n size: number\r\n color?: string\r\n gradient?: Gradient\r\n dasharray?: string\r\n margin?: number\r\n /**\r\n * If true, all dimensions are proportional to the code size,\r\n * i.e. `size: 0.1` means the border thickness is 1/10 of the QR code size\r\n *\r\n * This is useful to keep the border visually consistent regardless of the amount of data\r\n *\r\n * Note: if using dasharray, use percentage values to maintain consistency\r\n */\r\n proportional?: boolean\r\n text?: TextConfig & {\r\n [key in TextPosition]?: TextConfig & {\r\n content: string\r\n }\r\n }\r\n /**\r\n * A string of embedded CSS \\@font-face rules\r\n *\r\n * @deprecated Use @liquid-js/qr-code-styling/font-faces-plugin\r\n */\r\n fontFaces?: string\r\n}\r\n\r\nexport default class BorderPlugin implements Plugin {\r\n\r\n constructor(\r\n private readonly pluginOptions: BorderPluginOptions,\r\n /** @ignore Create unique id for SVG elements to prevent naming collisions; specify your own if neccesary e.g. for testing */\r\n private readonly idSuffix = Math.random().toFixed(10).substring(2)\r\n ) { }\r\n\r\n postProcess(svg: SVGSVGElement, options: Options, colors: {\r\n dots?: ColorElementValue\r\n background?: ColorElementValue\r\n }) {\r\n const { document } = options\r\n const sizeFactor = this.pluginOptions.proportional ? options.size : 1\r\n\r\n const margin = (this.pluginOptions.margin || 0) * sizeFactor\r\n let thickness = (this.pluginOptions.size) * sizeFactor\r\n const drawArea = extendSVG(svg, thickness + margin)\r\n if (!drawArea)\r\n return\r\n\r\n thickness = Math.abs(thickness)\r\n\r\n const cx = (drawArea.left + drawArea.right) / 2\r\n const cy = (drawArea.top + drawArea.bottom) / 2\r\n const lineSize = options.size / 2 * (1 - (this.pluginOptions.round || 0))\r\n const r = (Math.min(drawArea.right - drawArea.left - 2 * thickness, drawArea.bottom - drawArea.top - 2 * thickness) / 2) - lineSize + thickness / 2\r\n\r\n let pathR = this.pluginOptions.round ? r : 0\r\n let pathL = this.pluginOptions.round ? lineSize : lineSize + r\r\n\r\n const borderEl = document.createElementNS('http://www.w3.org/2000/svg', 'rect')\r\n borderEl.setAttribute('width', numToAttr((pathL + pathR) * 2))\r\n borderEl.setAttribute('height', numToAttr((pathL + pathR) * 2))\r\n borderEl.setAttribute('x', numToAttr(cx - pathL - pathR))\r\n borderEl.setAttribute('y', numToAttr(cy - pathL - pathR))\r\n borderEl.setAttribute('rx', numToAttr(pathR))\r\n borderEl.setAttribute('fill', 'none')\r\n borderEl.setAttribute('stroke-width', numToAttr(thickness))\r\n if (this.pluginOptions.dasharray) {\r\n borderEl.setAttribute('stroke-dasharray', this.pluginOptions.dasharray)\r\n }\r\n\r\n const value = createColor({\r\n options: this.pluginOptions.gradient,\r\n color: this.pluginOptions.color,\r\n additionalRotation: 0,\r\n x: cx - pathL - pathR,\r\n y: cy - pathL - pathR,\r\n height: 2 * pathR,\r\n width: 2 * pathR,\r\n name: `border-color-${this.idSuffix}`,\r\n dotSize: options.dotsOptions.size,\r\n document: options.document\r\n })\r\n\r\n if (value) {\r\n if (value.gradient) {\r\n let defs = Array.from(svg.childNodes).find(v => (v as HTMLElement).tagName.toUpperCase() == 'DEFS')\r\n if (!defs) {\r\n defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')\r\n svg.appendChild(defs)\r\n }\r\n defs.appendChild(value.gradient)\r\n }\r\n borderEl.setAttribute('stroke', value.value)\r\n\r\n if (value.opacity < 1) borderEl.setAttribute('stroke-opacity', value.opacity.toFixed(7))\r\n } else if (colors.dots) {\r\n borderEl.setAttribute('stroke', colors.dots.value)\r\n\r\n if (colors.dots.opacity < 1) borderEl.setAttribute('stroke-opacity', colors.dots.opacity.toFixed(7))\r\n }\r\n\r\n svg.appendChild(borderEl);\r\n\r\n [TextPosition.left, TextPosition.top, TextPosition.right, TextPosition.bottom].forEach(postion => {\r\n const textCfg = this.pluginOptions.text\r\n const config = textCfg?.[postion]\r\n if (config) {\r\n let defs = Array.from(svg.childNodes).find(v => (v as HTMLElement).tagName.toUpperCase() == 'DEFS')\r\n if (!defs) {\r\n defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')\r\n svg.appendChild(defs)\r\n }\r\n const element = document.createElementNS('http://www.w3.org/2000/svg', 'path')\r\n const size = (config.size || textCfg.size || 1) * sizeFactor\r\n pathR = this.pluginOptions.round ? r - size / 3 : 0\r\n pathL = this.pluginOptions.round ? lineSize : lineSize + (r - size / 3)\r\n switch (postion) {\r\n case TextPosition.top:\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx} ${cy + pathR + pathL}\r\n h ${-pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${-pathR}\r\n v ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${-pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${pathR}\r\n v ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${pathR}\r\n h ${-pathL}`\r\n )\r\n break\r\n case TextPosition.bottom:\r\n if (this.pluginOptions.round)\r\n pathR += size * 2 / 3\r\n else\r\n pathL += size * 2 / 3\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx} ${cy - pathR - pathL}\r\n h ${-pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${-pathR} ${pathR}\r\n v ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${pathR} ${pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${pathR} ${-pathR}\r\n v ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 0 ${-pathR} ${-pathR}\r\n h ${-pathL}`\r\n )\r\n break\r\n case TextPosition.left:\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx + pathR + pathL} ${cy}\r\n v ${pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${pathR}\r\n h ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${-pathR}\r\n v ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${-pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${pathR}\r\n v ${pathL}`\r\n )\r\n break\r\n case TextPosition.right:\r\n element.setAttribute(\r\n 'd',\r\n svgPath`M ${cx - pathR - pathL} ${cy}\r\n v ${-pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${-pathR}\r\n h ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${pathR} ${pathR}\r\n v ${2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${pathR}\r\n h ${-2 * pathL}\r\n a ${pathR} ${pathR} 0 0 1 ${-pathR} ${-pathR}\r\n v ${-pathL}`\r\n )\r\n break\r\n }\r\n const id = `border-text-${postion}-${this.idSuffix}`\r\n element.setAttribute('id', id)\r\n element.setAttribute('fill', 'none')\r\n\r\n const span = document.createElementNS('http://www.w3.org/2000/svg', 'tspan')\r\n span.setAttribute('font-family', config.font || textCfg.font || 'sans-serif')\r\n span.setAttribute('fill', config.color || textCfg.color || '#000')\r\n span.setAttribute('font-weight', numToAttr(config.fontWeight || textCfg.fontWeight || 'normal'))\r\n span.setAttribute('font-style', config.fontStyle || textCfg.fontStyle || 'normal')\r\n span.setAttribute('font-size', numToAttr(size))\r\n span.textContent = config.content\r\n\r\n const textPath = document.createElementNS('http://www.w3.org/2000/svg', 'textPath')\r\n textPath.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#' + id)\r\n textPath.setAttribute('startOffset', '50%')\r\n textPath.setAttribute('text-anchor', 'middle')\r\n textPath.appendChild(span)\r\n\r\n const text = document.createElementNS('http://www.w3.org/2000/svg', 'text')\r\n text.appendChild(textPath)\r\n\r\n defs.appendChild(element)\r\n svg.appendChild(text)\r\n }\r\n })\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n if (this.pluginOptions.fontFaces) {\r\n let defs = Array.from(svg.childNodes).find(v => (v as HTMLElement).tagName.toUpperCase() == 'DEFS')\r\n if (!defs) {\r\n defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')\r\n svg.appendChild(defs)\r\n }\r\n const style = document.createElementNS('http://www.w3.org/2000/svg', 'style')\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n style.textContent = this.pluginOptions.fontFaces\r\n defs.appendChild(style)\r\n }\r\n }\r\n}\r\n"],"names":["extendSVG","numToAttr","TextPosition","createColor","l","w","top","bottom","left","right","pluginOptions","idSuffix","constructor","Math","random","toFixed","substring","this","postProcess","svg","options","colors","document","sizeFactor","proportional","size","thickness","drawArea","margin","abs","cx","cy","round","min","lineSize","pathR","r","pathL","createElementNS","setAttribute","borderEl","dasharray","value","gradient","color","additionalRotation","x","y","height","width","name","dotSize","dotsOptions","defs","Array","from","childNodes","find","v","tagName","toUpperCase","appendChild","opacity","dots","forEach","postion","text","textCfg","config","element","svgPath","id","span","font","fontWeight","fontStyle","textContent","content","textPath","setAttributeNS","fontFaces","style"],"mappings":"oBAKKA,eACDC,aACAC,MAAA,gCAEAC,MAyCU,sBAAA,IAAAC,EAAAC,EAAAD,IAAA,CAAA,EAAAC,EAAAC,IAAA,MAAAD,EAAAE,OAAA,SAAAF,EAAAG,KAAA,OAAAH,EAAAI,MAAA,6BAGWC,cAEAC,SAHrBC,WAAAA,CACqBF,EAEAC,EAAWE,KAAKC,SAASC,QAAQ,IAAIC,UAAU,IAF/CC,KAAAP,cAAAA,EAEAO,KAAAN,SAAAA,CAAiD,CAGtEO,WAAAA,CAAYC,EAAoBC,EAAkBC,GAI9C,IAAMC,SAAAA,KACNC,EAAgBN,KAAGP,cAAKc,aAA0BJ,EAAGK,OAGjDC,EAAaT,KAAKP,cAAce,KAAQF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EAASvC,aAAa,cAAe,OACrCuC,EAASvC,aAAa,cAAe,UACrCuC,EAASjB,YAAYW,MAEXlD,EAAGgB,6CAAqD,SAC7DuB,YAAYiB,GAEjBzB,EAAKQ,YAAYQ,GACjBlD,EAAI0C,YAAYK,EAlGR,IAuGZjD,KAAKP,cAAcsE,aACf3B,EAAOC,MAAMC,KAAKpC,EAAIqC,YAAYC,KAAKC,GAAiD,QAA3CA,EAAkBC,QAAQC,kBAEvEP,EAAO/B,EAASgB,gBAAgB,6BAA8B,QAC9DnB,EAAI0C,YAAYR,KAEpB4B,EAAW3D,EAAGgB,6CAAqD,UAE7DsC,YAAc3D,KAAKP,cAAcsE,UACvC3B,EAAKQ,YAAYoB,GA7KrB,CAPH"}
|
package/lib/plugins/border.d.ts
CHANGED
|
@@ -245,8 +245,8 @@ let DotElements = {
|
|
|
245
245
|
element.setAttribute("d", parts.join(" ") + " z"), element;
|
|
246
246
|
},
|
|
247
247
|
circuit: (args, left = !1) => {
|
|
248
|
-
const {size, x, y, document} = args,
|
|
249
|
-
return element.setAttribute("d", svgPath`M ${x + .4 * size} ${y + .5 * size - dP} a ${.
|
|
248
|
+
const {size, x, y, document} = args, dP = .17 ** .5 * size, element = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
249
|
+
return element.setAttribute("d", svgPath`M ${x + .4 * size} ${y + .5 * size - dP} a ${.4 * size} ${.4 * size} 0 0 0 ${left ? .1 * size - dP : -.3 * size} ${left ? dP - .1 * size : dP} ${left ? svgPath`h ${-.3 * size} v ${.2 * size} h ${.3 * size} a ${.4 * size} ${.4 * size} 0 0 0 ${dP} ${.3 * size}` : svgPath`a ${.4 * size} ${.4 * size} 0 0 0 ${.4 * size} ${.4 * size}`} a ${.4 * size} ${.4 * size} 0 0 0 ${.4 * size} ${-.4 * size} a ${.4 * size} ${.4 * size} 0 0 0 ${-.3 * size} ${-dP} v ${-.3 * size} h ${-.2 * size} z`),
|
|
250
250
|
element.setAttribute("fill-rule", "nonzero"), element;
|
|
251
251
|
}
|
|
252
252
|
}, qrCornerDotFigures = {
|