qrcode.vue 3.6.0 → 3.7.0

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-zh_cn.md CHANGED
@@ -180,6 +180,7 @@ createApp({
180
180
  // 这意味着嵌入图像重叠的任何模块都将使用背景颜色。
181
181
  // 使用此选项可确保图像周围的边缘清晰。嵌入透明图像时也很有用。
182
182
  excavate?: boolean,
183
+ borderRadius?: number, // 图片的边框圆角。
183
184
  }
184
185
  ```
185
186
 
package/README.md CHANGED
@@ -179,6 +179,7 @@ The foreground color of qrcode.
179
179
  height: number, // The height of image
180
180
  width: number, // The height of image
181
181
  excavate?: boolean, // Whether or not to "excavate" the modules around the image.
182
+ borderRadius?: number, // The border radius of image.
182
183
  }
183
184
  ```
184
185
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * qrcode.vue v3.6.0
2
+ * qrcode.vue v3.7.0
3
3
  * A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3
4
4
  * © 2017-PRESENT @scopewu(https://github.com/scopewu)
5
5
  * MIT License.
@@ -910,6 +910,9 @@ var qrcodegen;
910
910
  var QR = qrcodegen;
911
911
 
912
912
  var defaultErrorCorrectLevel = 'L';
913
+ var DEFAULT_QR_SIZE = 100;
914
+ var DEFAULT_MARGIN = 0;
915
+ var DEFAULT_IMAGE_SIZE_RATIO = 0.1;
913
916
  var ErrorCorrectLevelMap = {
914
917
  L: QR.QrCode.Ecc.LOW,
915
918
  M: QR.QrCode.Ecc.MEDIUM,
@@ -929,16 +932,52 @@ var SUPPORTS_PATH2D = (function () {
929
932
  function validErrorCorrectLevel(level) {
930
933
  return level in ErrorCorrectLevelMap;
931
934
  }
935
+ function isPointInRoundedRect(px, py, rx, ry, rw, rh, r) {
936
+ // Fast check: point outside the bounding box
937
+ if (px < rx || px > rx + rw || py < ry || py > ry + rh) {
938
+ return false;
939
+ }
940
+ // If no border radius or point is in the center rectangle
941
+ if (r <= 0 || (px > rx + r && px < rx + rw - r) || (py > ry + r && py < ry + rh - r)) {
942
+ return true;
943
+ }
944
+ // Check the four corners
945
+ // Top-left corner
946
+ if (px < rx + r && py < ry + r) {
947
+ var dx = px - (rx + r);
948
+ var dy = py - (ry + r);
949
+ return dx * dx + dy * dy <= r * r;
950
+ }
951
+ // Top-right corner
952
+ if (px > rx + rw - r && py < ry + r) {
953
+ var dx = px - (rx + rw - r);
954
+ var dy = py - (ry + r);
955
+ return dx * dx + dy * dy <= r * r;
956
+ }
957
+ // Bottom-left corner
958
+ if (px < rx + r && py > ry + rh - r) {
959
+ var dx = px - (rx + r);
960
+ var dy = py - (ry + rh - r);
961
+ return dx * dx + dy * dy <= r * r;
962
+ }
963
+ // Bottom-right corner
964
+ if (px > rx + rw - r && py > ry + rh - r) {
965
+ var dx = px - (rx + rw - r);
966
+ var dy = py - (ry + rh - r);
967
+ return dx * dx + dy * dy <= r * r;
968
+ }
969
+ return true;
970
+ }
932
971
  function generatePath(modules, margin) {
933
972
  if (margin === void 0) { margin = 0; }
934
- var ops = [];
973
+ var path = '';
935
974
  modules.forEach(function (row, y) {
936
975
  var start = null;
937
976
  row.forEach(function (cell, x) {
938
977
  if (!cell && start !== null) {
939
978
  // M0 0h7v1H0z injects the space with the move and drops the comma,
940
979
  // saving a char per operation
941
- ops.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
980
+ path += "M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z");
942
981
  start = null;
943
982
  return;
944
983
  }
@@ -951,11 +990,11 @@ function generatePath(modules, margin) {
951
990
  }
952
991
  if (start === null) {
953
992
  // Just a single dark module.
954
- ops.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
993
+ path += "M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z");
955
994
  }
956
995
  else {
957
996
  // Otherwise finish the current line.
958
- ops.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
997
+ path += "M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z");
959
998
  }
960
999
  return;
961
1000
  }
@@ -964,12 +1003,12 @@ function generatePath(modules, margin) {
964
1003
  }
965
1004
  });
966
1005
  });
967
- return ops.join('');
1006
+ return path;
968
1007
  }
969
1008
  function getImageSettings(cells, size, margin, imageSettings) {
970
1009
  var width = imageSettings.width, height = imageSettings.height, imageX = imageSettings.x, imageY = imageSettings.y;
971
1010
  var numCells = cells.length + margin * 2;
972
- var defaultSize = Math.floor(size * 0.1);
1011
+ var defaultSize = Math.floor(size * DEFAULT_IMAGE_SIZE_RATIO);
973
1012
  var scale = numCells / size;
974
1013
  var w = (width || defaultSize) * scale;
975
1014
  var h = (height || defaultSize) * scale;
@@ -981,20 +1020,34 @@ function getImageSettings(cells, size, margin, imageSettings) {
981
1020
  var floorY = Math.floor(y);
982
1021
  var ceilW = Math.ceil(w + x - floorX);
983
1022
  var ceilH = Math.ceil(h + y - floorY);
984
- excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
1023
+ var borderRadius = (imageSettings.borderRadius || 0) * scale;
1024
+ excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH, borderRadius: borderRadius };
985
1025
  }
986
1026
  return { x: x, y: y, h: h, w: w, excavation: excavation };
987
1027
  }
988
1028
  function excavateModules(modules, excavation) {
989
- return modules.slice().map(function (row, y) {
990
- if (y < excavation.y || y >= excavation.y + excavation.h) {
991
- return row;
992
- }
1029
+ var borderRadius = excavation.borderRadius;
1030
+ // If no border radius, use simple rectangular excavation
1031
+ if (!borderRadius || borderRadius <= 0) {
1032
+ return modules.map(function (row, y) {
1033
+ if (y < excavation.y || y >= excavation.y + excavation.h) {
1034
+ return row;
1035
+ }
1036
+ return row.map(function (cell, x) {
1037
+ if (x < excavation.x || x >= excavation.x + excavation.w) {
1038
+ return cell;
1039
+ }
1040
+ return false;
1041
+ });
1042
+ });
1043
+ }
1044
+ // For rounded corners, check each module against the rounded rectangle shape
1045
+ return modules.map(function (row, y) {
993
1046
  return row.map(function (cell, x) {
994
- if (x < excavation.x || x >= excavation.x + excavation.w) {
1047
+ if (!cell)
995
1048
  return cell;
996
- }
997
- return false;
1049
+ var inExcavation = isPointInRoundedRect(x + 0.5, y + 0.5, excavation.x, excavation.y, excavation.w, excavation.h, borderRadius);
1050
+ return inExcavation ? false : cell;
998
1051
  });
999
1052
  });
1000
1053
  }
@@ -1006,7 +1059,7 @@ var QRCodeProps = {
1006
1059
  },
1007
1060
  size: {
1008
1061
  type: Number,
1009
- default: 100,
1062
+ default: DEFAULT_QR_SIZE,
1010
1063
  },
1011
1064
  level: {
1012
1065
  type: String,
@@ -1024,7 +1077,7 @@ var QRCodeProps = {
1024
1077
  margin: {
1025
1078
  type: Number,
1026
1079
  required: false,
1027
- default: 0,
1080
+ default: DEFAULT_MARGIN,
1028
1081
  },
1029
1082
  imageSettings: {
1030
1083
  type: Object,
@@ -1120,8 +1173,25 @@ var QrcodeSvg = vue.defineComponent({
1120
1173
  }),
1121
1174
  ]);
1122
1175
  };
1176
+ var renderClipPath = function () {
1177
+ var borderRadius = props.imageSettings.borderRadius || 0;
1178
+ if (!props.imageSettings.src)
1179
+ return null;
1180
+ if (borderRadius <= 0)
1181
+ return null;
1182
+ return vue.h('clipPath', { id: 'qr-logo-clip' }, [
1183
+ vue.h('rect', {
1184
+ x: imageProps.x,
1185
+ y: imageProps.y,
1186
+ width: imageProps.width,
1187
+ height: imageProps.height,
1188
+ rx: borderRadius,
1189
+ ry: borderRadius,
1190
+ }),
1191
+ ]);
1192
+ };
1123
1193
  generate();
1124
- vue.onUpdated(generate);
1194
+ vue.watch(props, generate, { deep: true });
1125
1195
  return function () { return vue.h('svg', {
1126
1196
  width: props.size,
1127
1197
  height: props.size,
@@ -1129,7 +1199,7 @@ var QrcodeSvg = vue.defineComponent({
1129
1199
  xmlns: 'http://www.w3.org/2000/svg',
1130
1200
  viewBox: "0 0 ".concat(numCells.value, " ").concat(numCells.value),
1131
1201
  }, [
1132
- vue.h('defs', {}, [renderGradient()]),
1202
+ vue.h('defs', {}, [renderGradient(), renderClipPath()]),
1133
1203
  vue.h('rect', {
1134
1204
  width: '100%',
1135
1205
  height: '100%',
@@ -1139,7 +1209,7 @@ var QrcodeSvg = vue.defineComponent({
1139
1209
  fill: props.gradient ? 'url(#qr-gradient)' : props.foreground,
1140
1210
  d: fgPath.value,
1141
1211
  }),
1142
- props.imageSettings.src && vue.h('image', __assign({ href: props.imageSettings.src }, imageProps)),
1212
+ props.imageSettings.src && vue.h('image', __assign(__assign({ href: props.imageSettings.src }, imageProps), (props.imageSettings.borderRadius ? { 'clip-path': 'url(#qr-logo-clip)' } : {}))),
1143
1213
  ]); };
1144
1214
  },
1145
1215
  });
@@ -1178,7 +1248,7 @@ var QrcodeCanvas = vue.defineComponent({
1178
1248
  cells = excavateModules(cells, imageSettings.excavation);
1179
1249
  }
1180
1250
  }
1181
- var devicePixelRatio = window.devicePixelRatio || 1;
1251
+ var devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
1182
1252
  var scale = (size / numCells) * devicePixelRatio;
1183
1253
  canvas.height = canvas.width = size * devicePixelRatio;
1184
1254
  ctx.scale(scale, scale);
@@ -1212,11 +1282,28 @@ var QrcodeCanvas = vue.defineComponent({
1212
1282
  });
1213
1283
  }
1214
1284
  if (showImage) {
1215
- ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1285
+ var borderRadius = props.imageSettings.borderRadius || 0;
1286
+ if (borderRadius > 0) {
1287
+ ctx.save();
1288
+ ctx.beginPath();
1289
+ if (ctx.roundRect) {
1290
+ ctx.roundRect(imageProps.x, imageProps.y, imageProps.width, imageProps.height, borderRadius);
1291
+ }
1292
+ else {
1293
+ // Fallback for browsers without roundRect support
1294
+ ctx.rect(imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1295
+ }
1296
+ ctx.clip();
1297
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1298
+ ctx.restore();
1299
+ }
1300
+ else {
1301
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1302
+ }
1216
1303
  }
1217
1304
  };
1218
1305
  vue.onMounted(generate);
1219
- vue.onUpdated(generate);
1306
+ vue.watch(props, generate, { deep: true });
1220
1307
  var style = ctx.attrs.style;
1221
1308
  return function () { return vue.h(vue.Fragment, [
1222
1309
  vue.h('canvas', __assign(__assign({}, ctx.attrs), { ref: canvasEl, style: __assign(__assign({}, style), { width: "".concat(props.size, "px"), height: "".concat(props.size, "px") }) })),
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * qrcode.vue v3.6.0
2
+ * qrcode.vue v3.7.0
3
3
  * A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3
4
4
  * © 2017-PRESENT @scopewu(https://github.com/scopewu)
5
5
  * MIT License.
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QrcodeVue={},e.Vue)}(this,(function(e,t){"use strict";var r,n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError,function(e){var t=function(){function t(e,r,n,i){if(this.version=e,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],t.MIN_VERSION>e||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(-1>i||i>7)throw new RangeError("Mask value out of range");this.size=4*e+17;for(var a=[],s=0;this.size>s;s++)a.push(!1);for(s=0;this.size>s;s++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();var u=this.addEccAndInterleave(n);if(this.drawCodewords(u),-1==i){var h=1e9;for(s=0;8>s;s++){this.applyMask(s),this.drawFormatBits(s);var l=this.getPenaltyScore();h>l&&(i=s,h=l),this.applyMask(s)}}o(i>=0&&7>=i),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}return t.encodeText=function(r,n){var o=e.QrSegment.makeSegments(r);return t.encodeSegments(o,n)},t.encodeBinary=function(r,n){var o=e.QrSegment.makeBytes(r);return t.encodeSegments([o],n)},t.encodeSegments=function(e,n,a,s,u,h){if(void 0===a&&(a=1),void 0===s&&(s=40),void 0===u&&(u=-1),void 0===h&&(h=!0),t.MIN_VERSION>a||a>s||s>t.MAX_VERSION||-1>u||u>7)throw new RangeError("Invalid value");var l,d;for(l=a;;l++){var f=8*t.getNumDataCodewords(l,n),c=i.getTotalBits(e,l);if(f>=c){d=c;break}if(l>=s)throw new RangeError("Data too long")}for(var g=0,v=[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH];v.length>g;g++){var p=v[g];h&&d<=8*t.getNumDataCodewords(l,p)&&(n=p)}for(var m=[],E=0,C=e;C.length>E;E++){var y=C[E];r(y.mode.modeBits,4,m),r(y.numChars,y.mode.numCharCountBits(l),m);for(var w=0,M=y.getData();M.length>w;w++){m.push(M[w])}}o(m.length==d);var R=8*t.getNumDataCodewords(l,n);o(R>=m.length),r(0,Math.min(4,R-m.length),m),r(0,(8-m.length%8)%8,m),o(m.length%8==0);for(var S=236;R>m.length;S^=253)r(S,8,m);for(var N=[];m.length>8*N.length;)N.push(0);return m.forEach((function(e,t){return N[t>>>3]|=e<<7-(7&t)})),new t(l,n,N,u)},t.prototype.getModule=function(e,t){return e>=0&&this.size>e&&t>=0&&this.size>t&&this.modules[t][e]},t.prototype.getModules=function(){return this.modules},t.prototype.drawFunctionPatterns=function(){for(var e=0;this.size>e;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);var t=this.getAlignmentPatternPositions(),r=t.length;for(e=0;r>e;e++)for(var n=0;r>n;n++)0==e&&0==n||0==e&&n==r-1||e==r-1&&0==n||this.drawAlignmentPattern(t[e],t[n]);this.drawFormatBits(0),this.drawVersion()},t.prototype.drawFormatBits=function(e){for(var t=this.errorCorrectionLevel.formatBits<<3|e,r=t,i=0;10>i;i++)r=r<<1^1335*(r>>>9);var a=21522^(t<<10|r);o(a>>>15==0);for(i=0;5>=i;i++)this.setFunctionModule(8,i,n(a,i));this.setFunctionModule(8,7,n(a,6)),this.setFunctionModule(8,8,n(a,7)),this.setFunctionModule(7,8,n(a,8));for(i=9;15>i;i++)this.setFunctionModule(14-i,8,n(a,i));for(i=0;8>i;i++)this.setFunctionModule(this.size-1-i,8,n(a,i));for(i=8;15>i;i++)this.setFunctionModule(8,this.size-15+i,n(a,i));this.setFunctionModule(8,this.size-8,!0)},t.prototype.drawVersion=function(){if(this.version>=7){for(var e=this.version,t=0;12>t;t++)e=e<<1^7973*(e>>>11);var r=this.version<<12|e;o(r>>>18==0);for(t=0;18>t;t++){var i=n(r,t),a=this.size-11+t%3,s=Math.floor(t/3);this.setFunctionModule(a,s,i),this.setFunctionModule(s,a,i)}}},t.prototype.drawFinderPattern=function(e,t){for(var r=-4;4>=r;r++)for(var n=-4;4>=n;n++){var o=Math.max(Math.abs(n),Math.abs(r)),i=e+n,a=t+r;i>=0&&this.size>i&&a>=0&&this.size>a&&this.setFunctionModule(i,a,2!=o&&4!=o)}},t.prototype.drawAlignmentPattern=function(e,t){for(var r=-2;2>=r;r++)for(var n=-2;2>=n;n++)this.setFunctionModule(e+n,t+r,1!=Math.max(Math.abs(n),Math.abs(r)))},t.prototype.setFunctionModule=function(e,t,r){this.modules[t][e]=r,this.isFunction[t][e]=!0},t.prototype.addEccAndInterleave=function(e){var r=this.version,n=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");for(var i=t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],s=Math.floor(t.getNumRawDataModules(r)/8),u=i-s%i,h=Math.floor(s/i),l=[],d=t.reedSolomonComputeDivisor(a),f=0,c=0;i>f;f++){var g=e.slice(c,c+h-a+(u>f?0:1));c+=g.length;var v=t.reedSolomonComputeRemainder(g,d);u>f&&g.push(0),l.push(g.concat(v))}var p=[],m=function(e){l.forEach((function(t,r){e==h-a&&u>r||p.push(t[e])}))};for(f=0;l[0].length>f;f++)m(f);return o(p.length==s),p},t.prototype.drawCodewords=function(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");for(var r=0,i=this.size-1;i>=1;i-=2){6==i&&(i=5);for(var a=0;this.size>a;a++)for(var s=0;2>s;s++){var u=i-s,h=!(i+1&2)?this.size-1-a:a;!this.isFunction[h][u]&&8*e.length>r&&(this.modules[h][u]=n(e[r>>>3],7-(7&r)),r++)}}o(r==8*e.length)},t.prototype.applyMask=function(e){if(0>e||e>7)throw new RangeError("Mask value out of range");for(var t=0;this.size>t;t++)for(var r=0;this.size>r;r++){var n=void 0;switch(e){case 0:n=(r+t)%2==0;break;case 1:n=t%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+t)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(t/2))%2==0;break;case 5:n=r*t%2+r*t%3==0;break;case 6:n=(r*t%2+r*t%3)%2==0;break;case 7:n=((r+t)%2+r*t%3)%2==0;break;default:throw Error("Unreachable")}!this.isFunction[t][r]&&n&&(this.modules[t][r]=!this.modules[t][r])}},t.prototype.getPenaltyScore=function(){for(var e=0,r=0;this.size>r;r++){for(var n=!1,i=0,a=[0,0,0,0,0,0,0],s=0;this.size>s;s++)this.modules[r][s]==n?5==++i?e+=t.PENALTY_N1:i>5&&e++:(this.finderPenaltyAddHistory(i,a),n||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),n=this.modules[r][s],i=1);e+=this.finderPenaltyTerminateAndCount(n,i,a)*t.PENALTY_N3}for(s=0;this.size>s;s++){n=!1;var u=0;for(a=[0,0,0,0,0,0,0],r=0;this.size>r;r++)this.modules[r][s]==n?5==++u?e+=t.PENALTY_N1:u>5&&e++:(this.finderPenaltyAddHistory(u,a),n||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),n=this.modules[r][s],u=1);e+=this.finderPenaltyTerminateAndCount(n,u,a)*t.PENALTY_N3}for(r=0;this.size-1>r;r++)for(s=0;this.size-1>s;s++){var h=this.modules[r][s];h==this.modules[r][s+1]&&h==this.modules[r+1][s]&&h==this.modules[r+1][s+1]&&(e+=t.PENALTY_N2)}for(var l=0,d=0,f=this.modules;f.length>d;d++){l=f[d].reduce((function(e,t){return e+(t?1:0)}),l)}var c=this.size*this.size,g=Math.ceil(Math.abs(20*l-10*c)/c)-1;return o(g>=0&&9>=g),o((e+=g*t.PENALTY_N4)>=0&&2568888>=e),e},t.prototype.getAlignmentPatternPositions=function(){if(1==this.version)return[];for(var e=Math.floor(this.version/7)+2,t=2*Math.floor((8*this.version+3*e+5)/(4*e-4)),r=[6],n=this.size-7;e>r.length;n-=t)r.splice(1,0,n);return r},t.getNumRawDataModules=function(e){if(t.MIN_VERSION>e||e>t.MAX_VERSION)throw new RangeError("Version number out of range");var r=(16*e+128)*e+64;if(e>=2){var n=Math.floor(e/7)+2;r-=(25*n-10)*n-55,7>e||(r-=36)}return o(r>=208&&29648>=r),r},t.getNumDataCodewords=function(e,r){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]},t.reedSolomonComputeDivisor=function(e){if(1>e||e>255)throw new RangeError("Degree out of range");for(var r=[],n=0;e-1>n;n++)r.push(0);r.push(1);var o=1;for(n=0;e>n;n++){for(var i=0;r.length>i;i++)r[i]=t.reedSolomonMultiply(r[i],o),r.length>i+1&&(r[i]^=r[i+1]);o=t.reedSolomonMultiply(o,2)}return r},t.reedSolomonComputeRemainder=function(e,r){for(var n=r.map((function(e){return 0})),o=function(e){var o=e^n.shift();n.push(0),r.forEach((function(e,r){return n[r]^=t.reedSolomonMultiply(e,o)}))},i=0,a=e;a.length>i;i++){o(a[i])}return n},t.reedSolomonMultiply=function(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");for(var r=0,n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(t>>>n&1)*e;return o(r>>>8==0),r},t.prototype.finderPenaltyCountPatterns=function(e){var t=e[1];o(3*this.size>=t);var r=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(!r||4*t>e[0]||t>e[6]?0:1)+(!r||4*t>e[6]||t>e[0]?0:1)},t.prototype.finderPenaltyTerminateAndCount=function(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),this.finderPenaltyAddHistory(t+=this.size,r),this.finderPenaltyCountPatterns(r)},t.prototype.finderPenaltyAddHistory=function(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)},t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t}();function r(e,t,r){if(0>t||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(var n=t-1;n>=0;n--)r.push(e>>>n&1)}function n(e,t){return!!(e>>>t&1)}function o(e){if(!e)throw Error("Assertion error")}e.QrCode=t;var i=function(){function e(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,0>t)throw new RangeError("Invalid argument");this.bitData=r.slice()}return e.makeBytes=function(t){for(var n=[],o=0,i=t;i.length>o;o++){r(i[o],8,n)}return new e(e.Mode.BYTE,t.length,n)},e.makeNumeric=function(t){if(!e.isNumeric(t))throw new RangeError("String contains non-numeric characters");for(var n=[],o=0;t.length>o;){var i=Math.min(t.length-o,3);r(parseInt(t.substring(o,o+i),10),3*i+1,n),o+=i}return new e(e.Mode.NUMERIC,t.length,n)},e.makeAlphanumeric=function(t){if(!e.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");var n,o=[];for(n=0;t.length>=n+2;n+=2){var i=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n));r(i+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n+1)),11,o)}return t.length>n&&r(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)),6,o),new e(e.Mode.ALPHANUMERIC,t.length,o)},e.makeSegments=function(t){return""==t?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]},e.makeEci=function(t){var n=[];if(0>t)throw new RangeError("ECI assignment value out of range");if(128>t)r(t,8,n);else if(16384>t)r(2,2,n),r(t,14,n);else{if(t>=1e6)throw new RangeError("ECI assignment value out of range");r(6,3,n),r(t,21,n)}return new e(e.Mode.ECI,0,n)},e.isNumeric=function(t){return e.NUMERIC_REGEX.test(t)},e.isAlphanumeric=function(t){return e.ALPHANUMERIC_REGEX.test(t)},e.prototype.getData=function(){return this.bitData.slice()},e.getTotalBits=function(e,t){for(var r=0,n=0,o=e;o.length>n;n++){var i=o[n],a=i.mode.numCharCountBits(t);if(i.numChars>=1<<a)return 1/0;r+=4+a+i.bitData.length}return r},e.toUtf8ByteArray=function(e){e=encodeURI(e);for(var t=[],r=0;e.length>r;r++)"%"!=e.charAt(r)?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return t},e.NUMERIC_REGEX=/^[0-9]*$/,e.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,e.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e}();e.QrSegment=i}(r||(r={})),function(e){var t,r;t=e.QrCode||(e.QrCode={}),r=function(){function e(e,t){this.ordinal=e,this.formatBits=t}return e.LOW=new e(0,1),e.MEDIUM=new e(1,0),e.QUARTILE=new e(2,3),e.HIGH=new e(3,2),e}(),t.Ecc=r}(r||(r={})),function(e){var t,r;t=e.QrSegment||(e.QrSegment={}),r=function(){function e(e,t){this.modeBits=e,this.numBitsCharCount=t}return e.prototype.numCharCountBits=function(e){return this.numBitsCharCount[Math.floor((e+7)/17)]},e.NUMERIC=new e(1,[10,12,14]),e.ALPHANUMERIC=new e(2,[9,11,13]),e.BYTE=new e(4,[8,16,16]),e.KANJI=new e(8,[8,10,12]),e.ECI=new e(7,[0,0,0]),e}(),t.Mode=r}(r||(r={}));var o=r,i={L:o.QrCode.Ecc.LOW,M:o.QrCode.Ecc.MEDIUM,Q:o.QrCode.Ecc.QUARTILE,H:o.QrCode.Ecc.HIGH},a=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();function s(e){return e in i}function u(e,t){void 0===t&&(t=0);var r=[];return e.forEach((function(e,n){var o=null;e.forEach((function(i,a){if(!i&&null!==o)return r.push("M".concat(o+t," ").concat(n+t,"h").concat(a-o,"v1H").concat(o+t,"z")),void(o=null);if(a!==e.length-1)i&&null===o&&(o=a);else{if(!i)return;r.push(null===o?"M".concat(a+t,",").concat(n+t," h1v1H").concat(a+t,"z"):"M".concat(o+t,",").concat(n+t," h").concat(a+1-o,"v1H").concat(o+t,"z"))}}))})),r.join("")}function h(e,t,r,n){var o=n.width,i=n.height,a=n.x,s=n.y,u=e.length+2*r,h=Math.floor(.1*t),l=u/t,d=(o||h)*l,f=(i||h)*l,c=null==a?e.length/2-d/2:a*l,g=null==s?e.length/2-f/2:s*l,v=null;if(n.excavate){var p=Math.floor(c),m=Math.floor(g);v={x:p,y:m,w:Math.ceil(d+c-p),h:Math.ceil(f+g-m)}}return{x:c,y:g,h:f,w:d,excavation:v}}function l(e,t){return e.slice().map((function(e,r){return t.y>r||r>=t.y+t.h?e:e.map((function(e,r){return(t.x>r||r>=t.x+t.w)&&e}))}))}var d={value:{type:String,required:!0,default:""},size:{type:Number,default:100},level:{type:String,default:"L",validator:function(e){return s(e)}},background:{type:String,default:"#fff"},foreground:{type:String,default:"#000"},margin:{type:Number,required:!1,default:0},imageSettings:{type:Object,required:!1,default:function(){return{}}},gradient:{type:Boolean,required:!1,default:!1},gradientType:{type:String,required:!1,default:"linear",validator:function(e){return["linear","radial"].indexOf(e)>-1}},gradientStartColor:{type:String,required:!1,default:"#000"},gradientEndColor:{type:String,required:!1,default:"#fff"}},f=n(n({},d),{renderAs:{type:String,required:!1,default:"canvas",validator:function(e){return["canvas","svg"].indexOf(e)>-1}}}),c=t.defineComponent({name:"QRCodeSvg",props:d,setup:function(e){var r,a=t.ref(0),d=t.ref(""),f=function(){var t=e.value,n=e.level,f=e.margin>>>0,c=s(n)?n:"L",g=o.QrCode.encodeText(t,i[c]).getModules();if(a.value=g.length+2*f,e.imageSettings.src){var v=h(g,e.size,f,e.imageSettings);r={x:v.x+f,y:v.y+f,width:v.w,height:v.h},v.excavation&&(g=l(g,v.excavation))}d.value=u(g,f)};return f(),t.onUpdated(f),function(){return t.h("svg",{width:e.size,height:e.size,"shape-rendering":"crispEdges",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(a.value," ").concat(a.value)},[t.h("defs",{},[e.gradient?t.h("linear"===e.gradientType?"linearGradient":"radialGradient",n({id:"qr-gradient"},"linear"===e.gradientType?{x1:"0%",y1:"0%",x2:"100%",y2:"100%"}:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"}),[t.h("stop",{offset:"0%",style:{stopColor:e.gradientStartColor}}),t.h("stop",{offset:"100%",style:{stopColor:e.gradientEndColor}})]):null]),t.h("rect",{width:"100%",height:"100%",fill:e.background}),t.h("path",{fill:e.gradient?"url(#qr-gradient)":e.foreground,d:d.value}),e.imageSettings.src&&t.h("image",n({href:e.imageSettings.src},r))])}}}),g=t.defineComponent({name:"QRCodeCanvas",props:d,setup:function(e,r){var d=t.ref(null),f=t.ref(null),c=function(){var t=e.value,r=e.level,n=e.size,c=e.background,g=e.foreground,v=e.gradient,p=e.gradientType,m=e.gradientStartColor,E=e.gradientEndColor,C=e.margin>>>0,y=s(r)?r:"L",w=d.value;if(w){var M=w.getContext("2d");if(M){var R=o.QrCode.encodeText(t,i[y]).getModules(),S=R.length+2*C,N=f.value,A={x:0,y:0,width:0,height:0},P=e.imageSettings.src&&null!=N&&0!==N.naturalWidth&&0!==N.naturalHeight;if(P){var I=h(R,e.size,C,e.imageSettings);A={x:I.x+C,y:I.y+C,width:I.w,height:I.h},I.excavation&&(R=l(R,I.excavation))}var _=window.devicePixelRatio||1,z=n/S*_;if(w.height=w.width=n*_,M.scale(z,z),M.fillStyle=c,M.fillRect(0,0,S,S),v){var O=void 0;(O="linear"===p?M.createLinearGradient(0,0,S,S):M.createRadialGradient(S/2,S/2,0,S/2,S/2,S/2)).addColorStop(0,m),O.addColorStop(1,E),M.fillStyle=O}else M.fillStyle=g;a?M.fill(new Path2D(u(R,C))):R.forEach((function(e,t){e.forEach((function(e,r){e&&M.fillRect(r+C,t+C,1,1)}))})),P&&M.drawImage(N,A.x,A.y,A.width,A.height)}}};t.onMounted(c),t.onUpdated(c);var g=r.attrs.style;return function(){return t.h(t.Fragment,[t.h("canvas",n(n({},r.attrs),{ref:d,style:n(n({},g),{width:"".concat(e.size,"px"),height:"".concat(e.size,"px")})})),e.imageSettings.src&&t.h("img",{ref:f,src:e.imageSettings.src,style:{display:"none"},onLoad:c})])}}}),v=t.defineComponent({name:"Qrcode",render:function(){var e=this.$props;return t.h("svg"===e.renderAs?c:g,{value:e.value,size:e.size,margin:e.margin,level:e.level,background:e.background,foreground:e.foreground,imageSettings:e.imageSettings,gradient:e.gradient,gradientType:e.gradientType,gradientStartColor:e.gradientStartColor,gradientEndColor:e.gradientEndColor})},props:f});e.QrcodeCanvas=g,e.QrcodeSvg=c,e.default=v,Object.defineProperty(e,"__esModule",{value:!0})}));
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QrcodeVue={},e.Vue)}(this,function(e,t){"use strict";var r,n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError,function(e){var t=function(){function t(e,r,n,o){if(this.version=e,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],t.MIN_VERSION>e||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(-1>o||o>7)throw new RangeError("Mask value out of range");this.size=4*e+17;for(var a=[],s=0;this.size>s;s++)a.push(!1);for(s=0;this.size>s;s++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();var u=this.addEccAndInterleave(n);if(this.drawCodewords(u),-1==o){var h=1e9;for(s=0;8>s;s++){this.applyMask(s),this.drawFormatBits(s);var d=this.getPenaltyScore();h>d&&(o=s,h=d),this.applyMask(s)}}i(o>=0&&7>=o),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}return t.encodeText=function(r,n){var i=e.QrSegment.makeSegments(r);return t.encodeSegments(i,n)},t.encodeBinary=function(r,n){var i=e.QrSegment.makeBytes(r);return t.encodeSegments([i],n)},t.encodeSegments=function(e,n,a,s,u,h){if(void 0===a&&(a=1),void 0===s&&(s=40),void 0===u&&(u=-1),void 0===h&&(h=!0),t.MIN_VERSION>a||a>s||s>t.MAX_VERSION||-1>u||u>7)throw new RangeError("Invalid value");var d,l;for(d=a;;d++){var f=8*t.getNumDataCodewords(d,n),c=o.getTotalBits(e,d);if(f>=c){l=c;break}if(d>=s)throw new RangeError("Data too long")}for(var g=0,v=[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH];v.length>g;g++){var p=v[g];h&&l<=8*t.getNumDataCodewords(d,p)&&(n=p)}for(var m=[],E=0,y=e;y.length>E;E++){var w=y[E];r(w.mode.modeBits,4,m),r(w.numChars,w.mode.numCharCountBits(d),m);for(var C=0,M=w.getData();M.length>C;C++){m.push(M[C])}}i(m.length==l);var R=8*t.getNumDataCodewords(d,n);i(R>=m.length),r(0,Math.min(4,R-m.length),m),r(0,(8-m.length%8)%8,m),i(m.length%8==0);for(var S=236;R>m.length;S^=253)r(S,8,m);for(var N=[];m.length>8*N.length;)N.push(0);return m.forEach(function(e,t){return N[t>>>3]|=e<<7-(7&t)}),new t(d,n,N,u)},t.prototype.getModule=function(e,t){return e>=0&&this.size>e&&t>=0&&this.size>t&&this.modules[t][e]},t.prototype.getModules=function(){return this.modules},t.prototype.drawFunctionPatterns=function(){for(var e=0;this.size>e;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);var t=this.getAlignmentPatternPositions(),r=t.length;for(e=0;r>e;e++)for(var n=0;r>n;n++)0==e&&0==n||0==e&&n==r-1||e==r-1&&0==n||this.drawAlignmentPattern(t[e],t[n]);this.drawFormatBits(0),this.drawVersion()},t.prototype.drawFormatBits=function(e){for(var t=this.errorCorrectionLevel.formatBits<<3|e,r=t,o=0;10>o;o++)r=r<<1^1335*(r>>>9);var a=21522^(t<<10|r);i(a>>>15==0);for(o=0;5>=o;o++)this.setFunctionModule(8,o,n(a,o));this.setFunctionModule(8,7,n(a,6)),this.setFunctionModule(8,8,n(a,7)),this.setFunctionModule(7,8,n(a,8));for(o=9;15>o;o++)this.setFunctionModule(14-o,8,n(a,o));for(o=0;8>o;o++)this.setFunctionModule(this.size-1-o,8,n(a,o));for(o=8;15>o;o++)this.setFunctionModule(8,this.size-15+o,n(a,o));this.setFunctionModule(8,this.size-8,!0)},t.prototype.drawVersion=function(){if(this.version>=7){for(var e=this.version,t=0;12>t;t++)e=e<<1^7973*(e>>>11);var r=this.version<<12|e;i(r>>>18==0);for(t=0;18>t;t++){var o=n(r,t),a=this.size-11+t%3,s=Math.floor(t/3);this.setFunctionModule(a,s,o),this.setFunctionModule(s,a,o)}}},t.prototype.drawFinderPattern=function(e,t){for(var r=-4;4>=r;r++)for(var n=-4;4>=n;n++){var i=Math.max(Math.abs(n),Math.abs(r)),o=e+n,a=t+r;o>=0&&this.size>o&&a>=0&&this.size>a&&this.setFunctionModule(o,a,2!=i&&4!=i)}},t.prototype.drawAlignmentPattern=function(e,t){for(var r=-2;2>=r;r++)for(var n=-2;2>=n;n++)this.setFunctionModule(e+n,t+r,1!=Math.max(Math.abs(n),Math.abs(r)))},t.prototype.setFunctionModule=function(e,t,r){this.modules[t][e]=r,this.isFunction[t][e]=!0},t.prototype.addEccAndInterleave=function(e){var r=this.version,n=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(r,n))throw new RangeError("Invalid argument");for(var o=t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],a=t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],s=Math.floor(t.getNumRawDataModules(r)/8),u=o-s%o,h=Math.floor(s/o),d=[],l=t.reedSolomonComputeDivisor(a),f=0,c=0;o>f;f++){var g=e.slice(c,c+h-a+(u>f?0:1));c+=g.length;var v=t.reedSolomonComputeRemainder(g,l);u>f&&g.push(0),d.push(g.concat(v))}var p=[],m=function(e){d.forEach(function(t,r){e==h-a&&u>r||p.push(t[e])})};for(f=0;d[0].length>f;f++)m(f);return i(p.length==s),p},t.prototype.drawCodewords=function(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");for(var r=0,o=this.size-1;o>=1;o-=2){6==o&&(o=5);for(var a=0;this.size>a;a++)for(var s=0;2>s;s++){var u=o-s,h=!(o+1&2)?this.size-1-a:a;!this.isFunction[h][u]&&8*e.length>r&&(this.modules[h][u]=n(e[r>>>3],7-(7&r)),r++)}}i(r==8*e.length)},t.prototype.applyMask=function(e){if(0>e||e>7)throw new RangeError("Mask value out of range");for(var t=0;this.size>t;t++)for(var r=0;this.size>r;r++){var n=void 0;switch(e){case 0:n=(r+t)%2==0;break;case 1:n=t%2==0;break;case 2:n=r%3==0;break;case 3:n=(r+t)%3==0;break;case 4:n=(Math.floor(r/3)+Math.floor(t/2))%2==0;break;case 5:n=r*t%2+r*t%3==0;break;case 6:n=(r*t%2+r*t%3)%2==0;break;case 7:n=((r+t)%2+r*t%3)%2==0;break;default:throw Error("Unreachable")}!this.isFunction[t][r]&&n&&(this.modules[t][r]=!this.modules[t][r])}},t.prototype.getPenaltyScore=function(){for(var e=0,r=0;this.size>r;r++){for(var n=!1,o=0,a=[0,0,0,0,0,0,0],s=0;this.size>s;s++)this.modules[r][s]==n?5==++o?e+=t.PENALTY_N1:o>5&&e++:(this.finderPenaltyAddHistory(o,a),n||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),n=this.modules[r][s],o=1);e+=this.finderPenaltyTerminateAndCount(n,o,a)*t.PENALTY_N3}for(s=0;this.size>s;s++){n=!1;var u=0;for(a=[0,0,0,0,0,0,0],r=0;this.size>r;r++)this.modules[r][s]==n?5==++u?e+=t.PENALTY_N1:u>5&&e++:(this.finderPenaltyAddHistory(u,a),n||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),n=this.modules[r][s],u=1);e+=this.finderPenaltyTerminateAndCount(n,u,a)*t.PENALTY_N3}for(r=0;this.size-1>r;r++)for(s=0;this.size-1>s;s++){var h=this.modules[r][s];h==this.modules[r][s+1]&&h==this.modules[r+1][s]&&h==this.modules[r+1][s+1]&&(e+=t.PENALTY_N2)}for(var d=0,l=0,f=this.modules;f.length>l;l++){d=f[l].reduce(function(e,t){return e+(t?1:0)},d)}var c=this.size*this.size,g=Math.ceil(Math.abs(20*d-10*c)/c)-1;return i(g>=0&&9>=g),i((e+=g*t.PENALTY_N4)>=0&&2568888>=e),e},t.prototype.getAlignmentPatternPositions=function(){if(1==this.version)return[];for(var e=Math.floor(this.version/7)+2,t=2*Math.floor((8*this.version+3*e+5)/(4*e-4)),r=[6],n=this.size-7;e>r.length;n-=t)r.splice(1,0,n);return r},t.getNumRawDataModules=function(e){if(t.MIN_VERSION>e||e>t.MAX_VERSION)throw new RangeError("Version number out of range");var r=(16*e+128)*e+64;if(e>=2){var n=Math.floor(e/7)+2;r-=(25*n-10)*n-55,7>e||(r-=36)}return i(r>=208&&29648>=r),r},t.getNumDataCodewords=function(e,r){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]},t.reedSolomonComputeDivisor=function(e){if(1>e||e>255)throw new RangeError("Degree out of range");for(var r=[],n=0;e-1>n;n++)r.push(0);r.push(1);var i=1;for(n=0;e>n;n++){for(var o=0;r.length>o;o++)r[o]=t.reedSolomonMultiply(r[o],i),r.length>o+1&&(r[o]^=r[o+1]);i=t.reedSolomonMultiply(i,2)}return r},t.reedSolomonComputeRemainder=function(e,r){for(var n=r.map(function(e){return 0}),i=function(e){var i=e^n.shift();n.push(0),r.forEach(function(e,r){return n[r]^=t.reedSolomonMultiply(e,i)})},o=0,a=e;a.length>o;o++){i(a[o])}return n},t.reedSolomonMultiply=function(e,t){if(e>>>8!=0||t>>>8!=0)throw new RangeError("Byte out of range");for(var r=0,n=7;n>=0;n--)r=r<<1^285*(r>>>7),r^=(t>>>n&1)*e;return i(r>>>8==0),r},t.prototype.finderPenaltyCountPatterns=function(e){var t=e[1];i(3*this.size>=t);var r=t>0&&e[2]==t&&e[3]==3*t&&e[4]==t&&e[5]==t;return(!r||4*t>e[0]||t>e[6]?0:1)+(!r||4*t>e[6]||t>e[0]?0:1)},t.prototype.finderPenaltyTerminateAndCount=function(e,t,r){return e&&(this.finderPenaltyAddHistory(t,r),t=0),this.finderPenaltyAddHistory(t+=this.size,r),this.finderPenaltyCountPatterns(r)},t.prototype.finderPenaltyAddHistory=function(e,t){0==t[0]&&(e+=this.size),t.pop(),t.unshift(e)},t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t}();function r(e,t,r){if(0>t||t>31||e>>>t!=0)throw new RangeError("Value out of range");for(var n=t-1;n>=0;n--)r.push(e>>>n&1)}function n(e,t){return!!(e>>>t&1)}function i(e){if(!e)throw Error("Assertion error")}e.QrCode=t;var o=function(){function e(e,t,r){if(this.mode=e,this.numChars=t,this.bitData=r,0>t)throw new RangeError("Invalid argument");this.bitData=r.slice()}return e.makeBytes=function(t){for(var n=[],i=0,o=t;o.length>i;i++){r(o[i],8,n)}return new e(e.Mode.BYTE,t.length,n)},e.makeNumeric=function(t){if(!e.isNumeric(t))throw new RangeError("String contains non-numeric characters");for(var n=[],i=0;t.length>i;){var o=Math.min(t.length-i,3);r(parseInt(t.substring(i,i+o),10),3*o+1,n),i+=o}return new e(e.Mode.NUMERIC,t.length,n)},e.makeAlphanumeric=function(t){if(!e.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");var n,i=[];for(n=0;t.length>=n+2;n+=2){var o=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n));r(o+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n+1)),11,i)}return t.length>n&&r(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)),6,i),new e(e.Mode.ALPHANUMERIC,t.length,i)},e.makeSegments=function(t){return""==t?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]},e.makeEci=function(t){var n=[];if(0>t)throw new RangeError("ECI assignment value out of range");if(128>t)r(t,8,n);else if(16384>t)r(2,2,n),r(t,14,n);else{if(t>=1e6)throw new RangeError("ECI assignment value out of range");r(6,3,n),r(t,21,n)}return new e(e.Mode.ECI,0,n)},e.isNumeric=function(t){return e.NUMERIC_REGEX.test(t)},e.isAlphanumeric=function(t){return e.ALPHANUMERIC_REGEX.test(t)},e.prototype.getData=function(){return this.bitData.slice()},e.getTotalBits=function(e,t){for(var r=0,n=0,i=e;i.length>n;n++){var o=i[n],a=o.mode.numCharCountBits(t);if(o.numChars>=1<<a)return 1/0;r+=4+a+o.bitData.length}return r},e.toUtf8ByteArray=function(e){e=encodeURI(e);for(var t=[],r=0;e.length>r;r++)"%"!=e.charAt(r)?t.push(e.charCodeAt(r)):(t.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return t},e.NUMERIC_REGEX=/^[0-9]*$/,e.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,e.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",e}();e.QrSegment=o}(r||(r={})),function(e){var t,r;t=e.QrCode||(e.QrCode={}),r=function(){function e(e,t){this.ordinal=e,this.formatBits=t}return e.LOW=new e(0,1),e.MEDIUM=new e(1,0),e.QUARTILE=new e(2,3),e.HIGH=new e(3,2),e}(),t.Ecc=r}(r||(r={})),function(e){var t,r;t=e.QrSegment||(e.QrSegment={}),r=function(){function e(e,t){this.modeBits=e,this.numBitsCharCount=t}return e.prototype.numCharCountBits=function(e){return this.numBitsCharCount[Math.floor((e+7)/17)]},e.NUMERIC=new e(1,[10,12,14]),e.ALPHANUMERIC=new e(2,[9,11,13]),e.BYTE=new e(4,[8,16,16]),e.KANJI=new e(8,[8,10,12]),e.ECI=new e(7,[0,0,0]),e}(),t.Mode=r}(r||(r={}));var i=r,o={L:i.QrCode.Ecc.LOW,M:i.QrCode.Ecc.MEDIUM,Q:i.QrCode.Ecc.QUARTILE,H:i.QrCode.Ecc.HIGH},a=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();function s(e){return e in o}function u(e,t){void 0===t&&(t=0);var r="";return e.forEach(function(e,n){var i=null;e.forEach(function(o,a){if(!o&&null!==i)return r+="M".concat(i+t," ").concat(n+t,"h").concat(a-i,"v1H").concat(i+t,"z"),void(i=null);if(a!==e.length-1)o&&null===i&&(i=a);else{if(!o)return;r+=null===i?"M".concat(a+t,",").concat(n+t," h1v1H").concat(a+t,"z"):"M".concat(i+t,",").concat(n+t," h").concat(a+1-i,"v1H").concat(i+t,"z")}})}),r}function h(e,t,r,n){var i=n.width,o=n.height,a=n.x,s=n.y,u=e.length+2*r,h=Math.floor(.1*t),d=u/t,l=(i||h)*d,f=(o||h)*d,c=null==a?e.length/2-l/2:a*d,g=null==s?e.length/2-f/2:s*d,v=null;if(n.excavate){var p=Math.floor(c),m=Math.floor(g);v={x:p,y:m,w:Math.ceil(l+c-p),h:Math.ceil(f+g-m),borderRadius:(n.borderRadius||0)*d}}return{x:c,y:g,h:f,w:l,excavation:v}}function d(e,t){var r=t.borderRadius;return e.map(r&&r>0?function(e,n){return e.map(function(e,i){return e?!(a=n+.5,u=t.y,h=t.w,d=t.h,l=r,!((s=t.x)>(o=i+.5)||o>s+h||u>a||a>u+d||!(0>=l||o>s+l&&s+h-l>o||a>u+l&&u+d-l>a)&&(s+l>o&&u+l>a?l*l<(f=o-(s+l))*f+(c=a-(u+l))*c:o>s+h-l&&u+l>a?l*l<(f=o-(s+h-l))*f+(c=a-(u+l))*c:s+l>o&&a>u+d-l?l*l<(f=o-(s+l))*f+(c=a-(u+d-l))*c:o>s+h-l&&a>u+d-l&&l*l<(f=o-(s+h-l))*f+(c=a-(u+d-l))*c)))&&e:e;var o,a,s,u,h,d,l,f,c})}:function(e,r){return t.y>r||r>=t.y+t.h?e:e.map(function(e,r){return(t.x>r||r>=t.x+t.w)&&e})})}var l={value:{type:String,required:!0,default:""},size:{type:Number,default:100},level:{type:String,default:"L",validator:function(e){return s(e)}},background:{type:String,default:"#fff"},foreground:{type:String,default:"#000"},margin:{type:Number,required:!1,default:0},imageSettings:{type:Object,required:!1,default:function(){return{}}},gradient:{type:Boolean,required:!1,default:!1},gradientType:{type:String,required:!1,default:"linear",validator:function(e){return["linear","radial"].indexOf(e)>-1}},gradientStartColor:{type:String,required:!1,default:"#000"},gradientEndColor:{type:String,required:!1,default:"#fff"}},f=n(n({},l),{renderAs:{type:String,required:!1,default:"canvas",validator:function(e){return["canvas","svg"].indexOf(e)>-1}}}),c=t.defineComponent({name:"QRCodeSvg",props:l,setup:function(e){var r,a=t.ref(0),l=t.ref(""),f=function(){var t=e.value,n=e.level,f=e.margin>>>0,c=s(n)?n:"L",g=i.QrCode.encodeText(t,o[c]).getModules();if(a.value=g.length+2*f,e.imageSettings.src){var v=h(g,e.size,f,e.imageSettings);r={x:v.x+f,y:v.y+f,width:v.w,height:v.h},v.excavation&&(g=d(g,v.excavation))}l.value=u(g,f)};return f(),t.watch(e,f,{deep:!0}),function(){return t.h("svg",{width:e.size,height:e.size,"shape-rendering":"crispEdges",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(a.value," ").concat(a.value)},[t.h("defs",{},[e.gradient?t.h("linear"===e.gradientType?"linearGradient":"radialGradient",n({id:"qr-gradient"},"linear"===e.gradientType?{x1:"0%",y1:"0%",x2:"100%",y2:"100%"}:{cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"}),[t.h("stop",{offset:"0%",style:{stopColor:e.gradientStartColor}}),t.h("stop",{offset:"100%",style:{stopColor:e.gradientEndColor}})]):null,(i=e.imageSettings.borderRadius||0,e.imageSettings.src&&i>0?t.h("clipPath",{id:"qr-logo-clip"},[t.h("rect",{x:r.x,y:r.y,width:r.width,height:r.height,rx:i,ry:i})]):null)]),t.h("rect",{width:"100%",height:"100%",fill:e.background}),t.h("path",{fill:e.gradient?"url(#qr-gradient)":e.foreground,d:l.value}),e.imageSettings.src&&t.h("image",n(n({href:e.imageSettings.src},r),e.imageSettings.borderRadius?{"clip-path":"url(#qr-logo-clip)"}:{}))]);var i}}}),g=t.defineComponent({name:"QRCodeCanvas",props:l,setup:function(e,r){var l=t.ref(null),f=t.ref(null),c=function(){var t=e.value,r=e.level,n=e.size,c=e.background,g=e.foreground,v=e.gradient,p=e.gradientType,m=e.gradientStartColor,E=e.gradientEndColor,y=e.margin>>>0,w=s(r)?r:"L",C=l.value;if(C){var M=C.getContext("2d");if(M){var R=i.QrCode.encodeText(t,o[w]).getModules(),S=R.length+2*y,N=f.value,A={x:0,y:0,width:0,height:0},P=e.imageSettings.src&&null!=N&&0!==N.naturalWidth&&0!==N.naturalHeight;if(P){var I=h(R,e.size,y,e.imageSettings);A={x:I.x+y,y:I.y+y,width:I.w,height:I.h},I.excavation&&(R=d(R,I.excavation))}var _="undefined"!=typeof window&&window.devicePixelRatio||1,x=n/S*_;if(C.height=C.width=n*_,M.scale(x,x),M.fillStyle=c,M.fillRect(0,0,S,S),v){var b=void 0;(b="linear"===p?M.createLinearGradient(0,0,S,S):M.createRadialGradient(S/2,S/2,0,S/2,S/2,S/2)).addColorStop(0,m),b.addColorStop(1,E),M.fillStyle=b}else M.fillStyle=g;if(a?M.fill(new Path2D(u(R,y))):R.forEach(function(e,t){e.forEach(function(e,r){e&&M.fillRect(r+y,t+y,1,1)})}),P){var z=e.imageSettings.borderRadius||0;z>0?(M.save(),M.beginPath(),M.roundRect?M.roundRect(A.x,A.y,A.width,A.height,z):M.rect(A.x,A.y,A.width,A.height),M.clip(),M.drawImage(N,A.x,A.y,A.width,A.height),M.restore()):M.drawImage(N,A.x,A.y,A.width,A.height)}}}};t.onMounted(c),t.watch(e,c,{deep:!0});var g=r.attrs.style;return function(){return t.h(t.Fragment,[t.h("canvas",n(n({},r.attrs),{ref:l,style:n(n({},g),{width:"".concat(e.size,"px"),height:"".concat(e.size,"px")})})),e.imageSettings.src&&t.h("img",{ref:f,src:e.imageSettings.src,style:{display:"none"},onLoad:c})])}}}),v=t.defineComponent({name:"Qrcode",render:function(){var e=this.$props;return t.h("svg"===e.renderAs?c:g,{value:e.value,size:e.size,margin:e.margin,level:e.level,background:e.background,foreground:e.foreground,imageSettings:e.imageSettings,gradient:e.gradient,gradientType:e.gradientType,gradientStartColor:e.gradientStartColor,gradientEndColor:e.gradientEndColor})},props:f});e.QrcodeCanvas=g,e.QrcodeSvg=c,e.default=v,Object.defineProperty(e,"__esModule",{value:!0})});
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * qrcode.vue v3.6.0
2
+ * qrcode.vue v3.7.0
3
3
  * A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3
4
4
  * © 2017-PRESENT @scopewu(https://github.com/scopewu)
5
5
  * MIT License.
@@ -910,6 +910,9 @@ var qrcodegen;
910
910
  var QR = qrcodegen;
911
911
 
912
912
  var defaultErrorCorrectLevel = 'L';
913
+ var DEFAULT_QR_SIZE = 100;
914
+ var DEFAULT_MARGIN = 0;
915
+ var DEFAULT_IMAGE_SIZE_RATIO = 0.1;
913
916
  var ErrorCorrectLevelMap = {
914
917
  L: QR.QrCode.Ecc.LOW,
915
918
  M: QR.QrCode.Ecc.MEDIUM,
@@ -929,16 +932,52 @@ var SUPPORTS_PATH2D = (function () {
929
932
  function validErrorCorrectLevel(level) {
930
933
  return level in ErrorCorrectLevelMap;
931
934
  }
935
+ function isPointInRoundedRect(px, py, rx, ry, rw, rh, r) {
936
+ // Fast check: point outside the bounding box
937
+ if (px < rx || px > rx + rw || py < ry || py > ry + rh) {
938
+ return false;
939
+ }
940
+ // If no border radius or point is in the center rectangle
941
+ if (r <= 0 || (px > rx + r && px < rx + rw - r) || (py > ry + r && py < ry + rh - r)) {
942
+ return true;
943
+ }
944
+ // Check the four corners
945
+ // Top-left corner
946
+ if (px < rx + r && py < ry + r) {
947
+ var dx = px - (rx + r);
948
+ var dy = py - (ry + r);
949
+ return dx * dx + dy * dy <= r * r;
950
+ }
951
+ // Top-right corner
952
+ if (px > rx + rw - r && py < ry + r) {
953
+ var dx = px - (rx + rw - r);
954
+ var dy = py - (ry + r);
955
+ return dx * dx + dy * dy <= r * r;
956
+ }
957
+ // Bottom-left corner
958
+ if (px < rx + r && py > ry + rh - r) {
959
+ var dx = px - (rx + r);
960
+ var dy = py - (ry + rh - r);
961
+ return dx * dx + dy * dy <= r * r;
962
+ }
963
+ // Bottom-right corner
964
+ if (px > rx + rw - r && py > ry + rh - r) {
965
+ var dx = px - (rx + rw - r);
966
+ var dy = py - (ry + rh - r);
967
+ return dx * dx + dy * dy <= r * r;
968
+ }
969
+ return true;
970
+ }
932
971
  function generatePath(modules, margin) {
933
972
  if (margin === void 0) { margin = 0; }
934
- var ops = [];
973
+ var path = '';
935
974
  modules.forEach(function (row, y) {
936
975
  var start = null;
937
976
  row.forEach(function (cell, x) {
938
977
  if (!cell && start !== null) {
939
978
  // M0 0h7v1H0z injects the space with the move and drops the comma,
940
979
  // saving a char per operation
941
- ops.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
980
+ path += "M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z");
942
981
  start = null;
943
982
  return;
944
983
  }
@@ -951,11 +990,11 @@ function generatePath(modules, margin) {
951
990
  }
952
991
  if (start === null) {
953
992
  // Just a single dark module.
954
- ops.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
993
+ path += "M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z");
955
994
  }
956
995
  else {
957
996
  // Otherwise finish the current line.
958
- ops.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
997
+ path += "M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z");
959
998
  }
960
999
  return;
961
1000
  }
@@ -964,12 +1003,12 @@ function generatePath(modules, margin) {
964
1003
  }
965
1004
  });
966
1005
  });
967
- return ops.join('');
1006
+ return path;
968
1007
  }
969
1008
  function getImageSettings(cells, size, margin, imageSettings) {
970
1009
  var width = imageSettings.width, height = imageSettings.height, imageX = imageSettings.x, imageY = imageSettings.y;
971
1010
  var numCells = cells.length + margin * 2;
972
- var defaultSize = Math.floor(size * 0.1);
1011
+ var defaultSize = Math.floor(size * DEFAULT_IMAGE_SIZE_RATIO);
973
1012
  var scale = numCells / size;
974
1013
  var w = (width || defaultSize) * scale;
975
1014
  var h = (height || defaultSize) * scale;
@@ -981,20 +1020,34 @@ function getImageSettings(cells, size, margin, imageSettings) {
981
1020
  var floorY = Math.floor(y);
982
1021
  var ceilW = Math.ceil(w + x - floorX);
983
1022
  var ceilH = Math.ceil(h + y - floorY);
984
- excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
1023
+ var borderRadius = (imageSettings.borderRadius || 0) * scale;
1024
+ excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH, borderRadius: borderRadius };
985
1025
  }
986
1026
  return { x: x, y: y, h: h, w: w, excavation: excavation };
987
1027
  }
988
1028
  function excavateModules(modules, excavation) {
989
- return modules.slice().map(function (row, y) {
990
- if (y < excavation.y || y >= excavation.y + excavation.h) {
991
- return row;
992
- }
1029
+ var borderRadius = excavation.borderRadius;
1030
+ // If no border radius, use simple rectangular excavation
1031
+ if (!borderRadius || borderRadius <= 0) {
1032
+ return modules.map(function (row, y) {
1033
+ if (y < excavation.y || y >= excavation.y + excavation.h) {
1034
+ return row;
1035
+ }
1036
+ return row.map(function (cell, x) {
1037
+ if (x < excavation.x || x >= excavation.x + excavation.w) {
1038
+ return cell;
1039
+ }
1040
+ return false;
1041
+ });
1042
+ });
1043
+ }
1044
+ // For rounded corners, check each module against the rounded rectangle shape
1045
+ return modules.map(function (row, y) {
993
1046
  return row.map(function (cell, x) {
994
- if (x < excavation.x || x >= excavation.x + excavation.w) {
1047
+ if (!cell)
995
1048
  return cell;
996
- }
997
- return false;
1049
+ var inExcavation = isPointInRoundedRect(x + 0.5, y + 0.5, excavation.x, excavation.y, excavation.w, excavation.h, borderRadius);
1050
+ return inExcavation ? false : cell;
998
1051
  });
999
1052
  });
1000
1053
  }
@@ -1006,7 +1059,7 @@ var QRCodeProps = {
1006
1059
  },
1007
1060
  size: {
1008
1061
  type: Number,
1009
- default: 100,
1062
+ default: DEFAULT_QR_SIZE,
1010
1063
  },
1011
1064
  level: {
1012
1065
  type: String,
@@ -1024,7 +1077,7 @@ var QRCodeProps = {
1024
1077
  margin: {
1025
1078
  type: Number,
1026
1079
  required: false,
1027
- default: 0,
1080
+ default: DEFAULT_MARGIN,
1028
1081
  },
1029
1082
  imageSettings: {
1030
1083
  type: Object,
@@ -1120,8 +1173,25 @@ var QrcodeSvg = vue.defineComponent({
1120
1173
  }),
1121
1174
  ]);
1122
1175
  };
1176
+ var renderClipPath = function () {
1177
+ var borderRadius = props.imageSettings.borderRadius || 0;
1178
+ if (!props.imageSettings.src)
1179
+ return null;
1180
+ if (borderRadius <= 0)
1181
+ return null;
1182
+ return vue.h('clipPath', { id: 'qr-logo-clip' }, [
1183
+ vue.h('rect', {
1184
+ x: imageProps.x,
1185
+ y: imageProps.y,
1186
+ width: imageProps.width,
1187
+ height: imageProps.height,
1188
+ rx: borderRadius,
1189
+ ry: borderRadius,
1190
+ }),
1191
+ ]);
1192
+ };
1123
1193
  generate();
1124
- vue.onUpdated(generate);
1194
+ vue.watch(props, generate, { deep: true });
1125
1195
  return function () { return vue.h('svg', {
1126
1196
  width: props.size,
1127
1197
  height: props.size,
@@ -1129,7 +1199,7 @@ var QrcodeSvg = vue.defineComponent({
1129
1199
  xmlns: 'http://www.w3.org/2000/svg',
1130
1200
  viewBox: "0 0 ".concat(numCells.value, " ").concat(numCells.value),
1131
1201
  }, [
1132
- vue.h('defs', {}, [renderGradient()]),
1202
+ vue.h('defs', {}, [renderGradient(), renderClipPath()]),
1133
1203
  vue.h('rect', {
1134
1204
  width: '100%',
1135
1205
  height: '100%',
@@ -1139,7 +1209,7 @@ var QrcodeSvg = vue.defineComponent({
1139
1209
  fill: props.gradient ? 'url(#qr-gradient)' : props.foreground,
1140
1210
  d: fgPath.value,
1141
1211
  }),
1142
- props.imageSettings.src && vue.h('image', __assign({ href: props.imageSettings.src }, imageProps)),
1212
+ props.imageSettings.src && vue.h('image', __assign(__assign({ href: props.imageSettings.src }, imageProps), (props.imageSettings.borderRadius ? { 'clip-path': 'url(#qr-logo-clip)' } : {}))),
1143
1213
  ]); };
1144
1214
  },
1145
1215
  });
@@ -1178,7 +1248,7 @@ var QrcodeCanvas = vue.defineComponent({
1178
1248
  cells = excavateModules(cells, imageSettings.excavation);
1179
1249
  }
1180
1250
  }
1181
- var devicePixelRatio = window.devicePixelRatio || 1;
1251
+ var devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
1182
1252
  var scale = (size / numCells) * devicePixelRatio;
1183
1253
  canvas.height = canvas.width = size * devicePixelRatio;
1184
1254
  ctx.scale(scale, scale);
@@ -1212,11 +1282,28 @@ var QrcodeCanvas = vue.defineComponent({
1212
1282
  });
1213
1283
  }
1214
1284
  if (showImage) {
1215
- ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1285
+ var borderRadius = props.imageSettings.borderRadius || 0;
1286
+ if (borderRadius > 0) {
1287
+ ctx.save();
1288
+ ctx.beginPath();
1289
+ if (ctx.roundRect) {
1290
+ ctx.roundRect(imageProps.x, imageProps.y, imageProps.width, imageProps.height, borderRadius);
1291
+ }
1292
+ else {
1293
+ // Fallback for browsers without roundRect support
1294
+ ctx.rect(imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1295
+ }
1296
+ ctx.clip();
1297
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1298
+ ctx.restore();
1299
+ }
1300
+ else {
1301
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1302
+ }
1216
1303
  }
1217
1304
  };
1218
1305
  vue.onMounted(generate);
1219
- vue.onUpdated(generate);
1306
+ vue.watch(props, generate, { deep: true });
1220
1307
  var style = ctx.attrs.style;
1221
1308
  return function () { return vue.h(vue.Fragment, [
1222
1309
  vue.h('canvas', __assign(__assign({}, ctx.attrs), { ref: canvasEl, style: __assign(__assign({}, style), { width: "".concat(props.size, "px"), height: "".concat(props.size, "px") }) })),
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * qrcode.vue v3.6.0
2
+ * qrcode.vue v3.7.0
3
3
  * A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3
4
4
  * © 2017-PRESENT @scopewu(https://github.com/scopewu)
5
5
  * MIT License.
6
6
  */
7
- import { defineComponent, ref, onUpdated, h, onMounted, Fragment } from 'vue';
7
+ import { defineComponent, ref, watch, h, onMounted, Fragment } from 'vue';
8
8
 
9
9
  /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -906,6 +906,9 @@ var qrcodegen;
906
906
  var QR = qrcodegen;
907
907
 
908
908
  var defaultErrorCorrectLevel = 'L';
909
+ var DEFAULT_QR_SIZE = 100;
910
+ var DEFAULT_MARGIN = 0;
911
+ var DEFAULT_IMAGE_SIZE_RATIO = 0.1;
909
912
  var ErrorCorrectLevelMap = {
910
913
  L: QR.QrCode.Ecc.LOW,
911
914
  M: QR.QrCode.Ecc.MEDIUM,
@@ -925,16 +928,52 @@ var SUPPORTS_PATH2D = (function () {
925
928
  function validErrorCorrectLevel(level) {
926
929
  return level in ErrorCorrectLevelMap;
927
930
  }
931
+ function isPointInRoundedRect(px, py, rx, ry, rw, rh, r) {
932
+ // Fast check: point outside the bounding box
933
+ if (px < rx || px > rx + rw || py < ry || py > ry + rh) {
934
+ return false;
935
+ }
936
+ // If no border radius or point is in the center rectangle
937
+ if (r <= 0 || (px > rx + r && px < rx + rw - r) || (py > ry + r && py < ry + rh - r)) {
938
+ return true;
939
+ }
940
+ // Check the four corners
941
+ // Top-left corner
942
+ if (px < rx + r && py < ry + r) {
943
+ var dx = px - (rx + r);
944
+ var dy = py - (ry + r);
945
+ return dx * dx + dy * dy <= r * r;
946
+ }
947
+ // Top-right corner
948
+ if (px > rx + rw - r && py < ry + r) {
949
+ var dx = px - (rx + rw - r);
950
+ var dy = py - (ry + r);
951
+ return dx * dx + dy * dy <= r * r;
952
+ }
953
+ // Bottom-left corner
954
+ if (px < rx + r && py > ry + rh - r) {
955
+ var dx = px - (rx + r);
956
+ var dy = py - (ry + rh - r);
957
+ return dx * dx + dy * dy <= r * r;
958
+ }
959
+ // Bottom-right corner
960
+ if (px > rx + rw - r && py > ry + rh - r) {
961
+ var dx = px - (rx + rw - r);
962
+ var dy = py - (ry + rh - r);
963
+ return dx * dx + dy * dy <= r * r;
964
+ }
965
+ return true;
966
+ }
928
967
  function generatePath(modules, margin) {
929
968
  if (margin === void 0) { margin = 0; }
930
- var ops = [];
969
+ var path = '';
931
970
  modules.forEach(function (row, y) {
932
971
  var start = null;
933
972
  row.forEach(function (cell, x) {
934
973
  if (!cell && start !== null) {
935
974
  // M0 0h7v1H0z injects the space with the move and drops the comma,
936
975
  // saving a char per operation
937
- ops.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
976
+ path += "M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z");
938
977
  start = null;
939
978
  return;
940
979
  }
@@ -947,11 +986,11 @@ function generatePath(modules, margin) {
947
986
  }
948
987
  if (start === null) {
949
988
  // Just a single dark module.
950
- ops.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
989
+ path += "M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z");
951
990
  }
952
991
  else {
953
992
  // Otherwise finish the current line.
954
- ops.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
993
+ path += "M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z");
955
994
  }
956
995
  return;
957
996
  }
@@ -960,12 +999,12 @@ function generatePath(modules, margin) {
960
999
  }
961
1000
  });
962
1001
  });
963
- return ops.join('');
1002
+ return path;
964
1003
  }
965
1004
  function getImageSettings(cells, size, margin, imageSettings) {
966
1005
  var width = imageSettings.width, height = imageSettings.height, imageX = imageSettings.x, imageY = imageSettings.y;
967
1006
  var numCells = cells.length + margin * 2;
968
- var defaultSize = Math.floor(size * 0.1);
1007
+ var defaultSize = Math.floor(size * DEFAULT_IMAGE_SIZE_RATIO);
969
1008
  var scale = numCells / size;
970
1009
  var w = (width || defaultSize) * scale;
971
1010
  var h = (height || defaultSize) * scale;
@@ -977,20 +1016,34 @@ function getImageSettings(cells, size, margin, imageSettings) {
977
1016
  var floorY = Math.floor(y);
978
1017
  var ceilW = Math.ceil(w + x - floorX);
979
1018
  var ceilH = Math.ceil(h + y - floorY);
980
- excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH };
1019
+ var borderRadius = (imageSettings.borderRadius || 0) * scale;
1020
+ excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH, borderRadius: borderRadius };
981
1021
  }
982
1022
  return { x: x, y: y, h: h, w: w, excavation: excavation };
983
1023
  }
984
1024
  function excavateModules(modules, excavation) {
985
- return modules.slice().map(function (row, y) {
986
- if (y < excavation.y || y >= excavation.y + excavation.h) {
987
- return row;
988
- }
1025
+ var borderRadius = excavation.borderRadius;
1026
+ // If no border radius, use simple rectangular excavation
1027
+ if (!borderRadius || borderRadius <= 0) {
1028
+ return modules.map(function (row, y) {
1029
+ if (y < excavation.y || y >= excavation.y + excavation.h) {
1030
+ return row;
1031
+ }
1032
+ return row.map(function (cell, x) {
1033
+ if (x < excavation.x || x >= excavation.x + excavation.w) {
1034
+ return cell;
1035
+ }
1036
+ return false;
1037
+ });
1038
+ });
1039
+ }
1040
+ // For rounded corners, check each module against the rounded rectangle shape
1041
+ return modules.map(function (row, y) {
989
1042
  return row.map(function (cell, x) {
990
- if (x < excavation.x || x >= excavation.x + excavation.w) {
1043
+ if (!cell)
991
1044
  return cell;
992
- }
993
- return false;
1045
+ var inExcavation = isPointInRoundedRect(x + 0.5, y + 0.5, excavation.x, excavation.y, excavation.w, excavation.h, borderRadius);
1046
+ return inExcavation ? false : cell;
994
1047
  });
995
1048
  });
996
1049
  }
@@ -1002,7 +1055,7 @@ var QRCodeProps = {
1002
1055
  },
1003
1056
  size: {
1004
1057
  type: Number,
1005
- default: 100,
1058
+ default: DEFAULT_QR_SIZE,
1006
1059
  },
1007
1060
  level: {
1008
1061
  type: String,
@@ -1020,7 +1073,7 @@ var QRCodeProps = {
1020
1073
  margin: {
1021
1074
  type: Number,
1022
1075
  required: false,
1023
- default: 0,
1076
+ default: DEFAULT_MARGIN,
1024
1077
  },
1025
1078
  imageSettings: {
1026
1079
  type: Object,
@@ -1116,8 +1169,25 @@ var QrcodeSvg = defineComponent({
1116
1169
  }),
1117
1170
  ]);
1118
1171
  };
1172
+ var renderClipPath = function () {
1173
+ var borderRadius = props.imageSettings.borderRadius || 0;
1174
+ if (!props.imageSettings.src)
1175
+ return null;
1176
+ if (borderRadius <= 0)
1177
+ return null;
1178
+ return h('clipPath', { id: 'qr-logo-clip' }, [
1179
+ h('rect', {
1180
+ x: imageProps.x,
1181
+ y: imageProps.y,
1182
+ width: imageProps.width,
1183
+ height: imageProps.height,
1184
+ rx: borderRadius,
1185
+ ry: borderRadius,
1186
+ }),
1187
+ ]);
1188
+ };
1119
1189
  generate();
1120
- onUpdated(generate);
1190
+ watch(props, generate, { deep: true });
1121
1191
  return function () { return h('svg', {
1122
1192
  width: props.size,
1123
1193
  height: props.size,
@@ -1125,7 +1195,7 @@ var QrcodeSvg = defineComponent({
1125
1195
  xmlns: 'http://www.w3.org/2000/svg',
1126
1196
  viewBox: "0 0 ".concat(numCells.value, " ").concat(numCells.value),
1127
1197
  }, [
1128
- h('defs', {}, [renderGradient()]),
1198
+ h('defs', {}, [renderGradient(), renderClipPath()]),
1129
1199
  h('rect', {
1130
1200
  width: '100%',
1131
1201
  height: '100%',
@@ -1135,7 +1205,7 @@ var QrcodeSvg = defineComponent({
1135
1205
  fill: props.gradient ? 'url(#qr-gradient)' : props.foreground,
1136
1206
  d: fgPath.value,
1137
1207
  }),
1138
- props.imageSettings.src && h('image', __assign({ href: props.imageSettings.src }, imageProps)),
1208
+ props.imageSettings.src && h('image', __assign(__assign({ href: props.imageSettings.src }, imageProps), (props.imageSettings.borderRadius ? { 'clip-path': 'url(#qr-logo-clip)' } : {}))),
1139
1209
  ]); };
1140
1210
  },
1141
1211
  });
@@ -1174,7 +1244,7 @@ var QrcodeCanvas = defineComponent({
1174
1244
  cells = excavateModules(cells, imageSettings.excavation);
1175
1245
  }
1176
1246
  }
1177
- var devicePixelRatio = window.devicePixelRatio || 1;
1247
+ var devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
1178
1248
  var scale = (size / numCells) * devicePixelRatio;
1179
1249
  canvas.height = canvas.width = size * devicePixelRatio;
1180
1250
  ctx.scale(scale, scale);
@@ -1208,11 +1278,28 @@ var QrcodeCanvas = defineComponent({
1208
1278
  });
1209
1279
  }
1210
1280
  if (showImage) {
1211
- ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1281
+ var borderRadius = props.imageSettings.borderRadius || 0;
1282
+ if (borderRadius > 0) {
1283
+ ctx.save();
1284
+ ctx.beginPath();
1285
+ if (ctx.roundRect) {
1286
+ ctx.roundRect(imageProps.x, imageProps.y, imageProps.width, imageProps.height, borderRadius);
1287
+ }
1288
+ else {
1289
+ // Fallback for browsers without roundRect support
1290
+ ctx.rect(imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1291
+ }
1292
+ ctx.clip();
1293
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1294
+ ctx.restore();
1295
+ }
1296
+ else {
1297
+ ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
1298
+ }
1212
1299
  }
1213
1300
  };
1214
1301
  onMounted(generate);
1215
- onUpdated(generate);
1302
+ watch(props, generate, { deep: true });
1216
1303
  var style = ctx.attrs.style;
1217
1304
  return function () { return h(Fragment, [
1218
1305
  h('canvas', __assign(__assign({}, ctx.attrs), { ref: canvasEl, style: __assign(__assign({}, style), { width: "".concat(props.size, "px"), height: "".concat(props.size, "px") }) })),
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@rstest/core").RstestConfig;
2
+ export default _default;
@@ -9,6 +9,7 @@ export type ImageSettings = {
9
9
  height: number;
10
10
  width: number;
11
11
  excavate?: boolean;
12
+ borderRadius?: number;
12
13
  };
13
14
  export declare const QrcodeSvg: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
15
  value: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qrcode.vue",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3",
5
5
  "type": "module",
6
6
  "main": "./dist/qrcode.vue.cjs.js",
@@ -8,10 +8,10 @@
8
8
  "browser": "./dist/qrcode.vue.browser.js",
9
9
  "unpkg": "./dist/qrcode.vue.browser.min.js",
10
10
  "jsdelivr": "./dist/qrcode.vue.browser.min.js",
11
- "types": "./dist/index.d.ts",
11
+ "types": "./dist/src/index.d.ts",
12
12
  "exports": {
13
13
  ".": {
14
- "types": "./dist/index.d.ts",
14
+ "types": "./dist/src/index.d.ts",
15
15
  "import": "./dist/qrcode.vue.esm.js",
16
16
  "require": "./dist/qrcode.vue.cjs.js"
17
17
  },
@@ -19,7 +19,8 @@
19
19
  },
20
20
  "scripts": {
21
21
  "dev": "rsbuild dev",
22
- "build": "rollup -c"
22
+ "build": "rollup -c",
23
+ "test": "rstest"
23
24
  },
24
25
  "repository": "https://github.com/scopewu/qrcode.vue.git",
25
26
  "keywords": [
@@ -48,12 +49,13 @@
48
49
  "dependencies": {},
49
50
  "devDependencies": {
50
51
  "@rollup/plugin-terser": "^0.4.4",
51
- "@rsbuild/core": "^1.0.19",
52
- "@rsbuild/plugin-sass": "^1.1.0",
53
- "bootstrap": "^5.3.3",
54
- "rollup": "^4.24.3",
52
+ "@rsbuild/core": "^1.7.2",
53
+ "@rstest/core": "^0.8.1",
54
+ "@vue/test-utils": "^2.4.6",
55
+ "happy-dom": "^20.4.0",
56
+ "rollup": "^4.57.0",
55
57
  "rollup-plugin-typescript2": "^0.36.0",
56
- "typescript": "^5.6.3",
57
- "vue": "^3.5.12"
58
+ "typescript": "^5.9.3",
59
+ "vue": "^3.5.27"
58
60
  }
59
61
  }
package/CHANGELOG.md DELETED
@@ -1,111 +0,0 @@
1
- ## [3.5.0] - 2024-09-26
2
-
3
- ### Feature
4
-
5
- - Support logo image for Qrcode.
6
- - Exports separate `QrcodeCanvas` and `QrcodeSvg` components
7
-
8
- Direct references to `QrcodeVue` in common.js and cdn now require the `default` field:
9
-
10
- ```js
11
- const QrcodeVue = require('qrcode.vue').default
12
- const { default: QrcodeVue, QrcodeCanvas, QrcodeSvg } = require('qrcode.vue')
13
- ```
14
-
15
- ```html
16
- <!--With HTML-->
17
- <div id="root">
18
- <p class="flex space-x">
19
- <qrcode-vue :value="test" render-as="svg"></qrcode-vue>
20
- <qrcode-canvas :value="test"></qrcode-canvas>
21
- <qrcode-svg :value="test" :image-settings="imageSettings"></qrcode-svg>
22
- </p>
23
- <p><input v-model="test" /></p>
24
- </div>
25
- <script src="https://cdn.jsdelivr.net/npm/vue@3.5/dist/vue.global.prod.js"></script>
26
- <script src="https://cdn.jsdelivr.net/npm/qrcode.vue@3.5/dist/qrcode.vue.browser.min.js"></script>
27
-
28
- <script>
29
- Vue.createApp({
30
- data() { return {
31
- test: 'Hello World',
32
- imageSettings: {
33
- src: 'https://avatars.githubusercontent.com/u/15811268',
34
- width: 30,
35
- height: 30,
36
- excavate: true,
37
- },
38
- }},
39
- components: {
40
- QrcodeVue: QrcodeVue.default,
41
- QrcodeCanvas: QrcodeVue.QrcodeCanvas,
42
- QrcodeSvg: QrcodeVue.QrcodeSvg,
43
- },
44
- }).mount('#root')
45
- </script>
46
- ```
47
-
48
- ## [3.4.1] - 2023-08-05
49
-
50
- ### BUGFIX
51
-
52
- - Fixed TypeScript type export error.
53
-
54
- ## [3.4.0] - 2023-04-15
55
-
56
- ### Performance
57
-
58
- - remove `qr.js` dependency, use `nayuki/QR-Code-generator` instead.
59
-
60
- ## [3.3.1] - 2021-09-11
61
-
62
- ### BUGFIX
63
-
64
- - Fix document description error, adjust `renderAs` to `render-as`.
65
-
66
- ## [3.2.0] - 2020-12-20
67
-
68
- ### Feature
69
-
70
- - support typescript.
71
-
72
- ## [3.1.0] - 2020-12-20
73
-
74
- ### Feature
75
-
76
- - Add support margin for QRcode.
77
-
78
- ## [3.0.0] - 2020-12-20
79
-
80
- ### Feature
81
-
82
- - Support Vue 3
83
-
84
- ## [1.7.0] - 2019-11-10
85
-
86
- ### Feature
87
-
88
- - Support generate Qrcode as svg.
89
-
90
- ## [1.6.3] - 2019-09-16
91
-
92
- ### Update
93
-
94
- - Perfect documentation.
95
- - Add eslint check.
96
-
97
- ## [1.6.2] - 2019-05-21
98
-
99
- ### Remove:
100
-
101
- - `backingStorePixelRatio` is deprecated. more infomation [CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D).
102
-
103
- ## [1.6.0] - 2018-04-14
104
-
105
- ### Changed
106
-
107
- - Use Vue render function, not use jsx.
108
-
109
- ### Bugfixs
110
-
111
- - convert utf-16 to utf-8.
package/README-ja.md DELETED
@@ -1,267 +0,0 @@
1
- # qrcode.vue
2
-
3
- ⚠️ 現在、Vue 3.xを使用している場合は、`qrcode.vue` を`3.x`にアップグレードしてください。
4
-
5
- 🔒 Vue 2.xを使用している場合は、バージョン `1.x` を使用し続けてください。
6
-
7
- [QRコード](https://en.wikipedia.org/wiki/QR_code)を生成するための Vue.js コンポーネントです。Vue 2 と Vue 3 の両方をサポートしています。
8
-
9
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/scopewu/qrcode.vue/blob/main/LICENSE)
10
-
11
- [English](./README.md)
12
-
13
- ## インストール
14
-
15
- `qrcode.vue`コンポーネントを Vue.js アプリに使用できます。
16
-
17
- ```bash
18
- npm install --save qrcode.vue # yarn add qrcode.vue
19
- ```
20
-
21
- ```
22
- dist/
23
- |--- qrcode.vue.cjs.js // CommonJS
24
- |--- qrcode.vue.esm.js // ESモジュール
25
- |--- qrcode.vue.browser.js // ブラウザまたはrequire.jsまたはCommonJS用のUMD
26
- |--- qrcode.vue.browser.min.js // 最小サイズのUMD
27
- ```
28
-
29
- ## 使用方法
30
-
31
- e.g.
32
-
33
- ```javascript
34
- import { createApp } from 'vue'
35
- import QrcodeVue from 'qrcode.vue'
36
-
37
- createApp({
38
- data: {
39
- value: 'https://example.com',
40
- },
41
- template: '<qrcode-vue :value="value"></qrcode-vue>',
42
- components: {
43
- QrcodeVue,
44
- },
45
- }).mount('#root')
46
- ```
47
-
48
- または、`*.vue` 拡張子の単一ファイルコンポーネントで使用します:
49
-
50
- ```html
51
- <template>
52
- <qrcode-vue :value="value" :size="size" level="H" />
53
- </template>
54
- <script>
55
- import QrcodeVue from 'qrcode.vue'
56
-
57
- export default {
58
- data() {
59
- return {
60
- value: 'https://example.com',
61
- size: 300,
62
- }
63
- },
64
- components: {
65
- QrcodeVue,
66
- },
67
- }
68
- </script>
69
- ```
70
-
71
- Vue 3で `TypeScript` を使用する場合:
72
-
73
- ```html
74
- <template>
75
- <qrcode-vue
76
- :value="value"
77
- :level="level"
78
- :render-as="renderAs"
79
- :background="background"
80
- :foreground='foreground'
81
- :gradient="gradient"
82
- :gradient-type="gradientType"
83
- :gradient-start-color="gradientStartColor"
84
- :gradient-end-color="gradientEndColor"
85
- :image-settings='imageSettings'
86
- />
87
- </template>
88
- <script setup lang="ts">
89
- import { ref } from 'vue'
90
- import QrcodeVue from 'qrcode.vue'
91
- import type { Level, RenderAs, GradientType, ImageSettings } from 'qrcode.vue'
92
-
93
- const value = ref('qrcode')
94
- const level = ref<Level>('M')
95
- const renderAs = ref<RenderAs>('svg')
96
- const background = ref('#ffffff')
97
- const foreground = ref('#000000')
98
- const margin = ref(0)
99
-
100
- // 画像の設定
101
- const imageSettings = ref<ImageSettings>({
102
- src: 'https://github.com/scopewu.png',
103
- width: 30,
104
- height: 30,
105
- // x: 10,
106
- // y: 10,
107
- excavate: true,
108
- })
109
-
110
- // グラデーション
111
- const gradient = ref(false)
112
- const gradientType = ref<GradientType>('linear')
113
- const gradientStartColor = ref('#000000')
114
- const gradientEndColor = ref('#38bdf8')
115
- </script>
116
- ```
117
-
118
- ## コンポーネントプロパティ
119
-
120
- ### `value`
121
-
122
- - タイプ:`string`
123
- - デフォルト:`''`
124
-
125
- QRコードの内容。
126
-
127
- ### `size`
128
-
129
- - タイプ:`number`
130
- - デフォルト:`100`
131
-
132
- QRコード要素のサイズ。
133
-
134
- ### `render-as`
135
-
136
- - タイプ:`RenderAs('canvas' | 'svg')`
137
- - デフォルト:`canvas`
138
-
139
- `canvas`または`svg`としてQRコードを生成します。`svg`プロパティはSSRで動作します。
140
-
141
- ### `margin`
142
-
143
- - タイプ:`number`
144
- - デフォルト:`0`
145
-
146
- 静かなゾーンの幅を定義します。
147
-
148
- ### `level`
149
-
150
- - タイプ:`Level('L' | 'M' | 'Q' | 'H')`
151
- - デフォルト:`H`
152
-
153
- QRコードの誤り訂正レベル('L'、'M'、'Q'、'H'のいずれか)。詳細については、[wikipedia: QR_code](https://en.wikipedia.org/wiki/QR_code#Error_correction)を参照してください。
154
-
155
- ### `background`
156
-
157
- - タイプ:`string`
158
- - デフォルト:`#ffffff`
159
-
160
- QRコードの背景色。
161
-
162
- ### `foreground`
163
-
164
- - タイプ:`string`
165
- - デフォルト:`#000000`
166
-
167
- QRコードの前景色。
168
-
169
- ### `image-settings`
170
-
171
- - タイプ: `ImageSettings`
172
- - デフォルト: `{}`
173
-
174
- ```ts
175
- export type ImageSettings = {
176
- src: string, // The URL of image.
177
- x?: number, // The horizontal offset. When not specified, will center the image.
178
- y?: number, // The vertical offset. When not specified, will center the image.
179
- height: number, // The height of image
180
- width: number, // The height of image
181
- excavate?: boolean, // Whether or not to "excavate" the modules around the image.
182
- }
183
- ```
184
-
185
- The settings to support qrcode image logo.
186
-
187
- ### `gradient`
188
-
189
- - タイプ:`boolean`
190
- - デフォルト:`false`
191
-
192
- QRコードのグラデーション塗りつぶしを有効にします。
193
-
194
- ### `gradient-type`
195
-
196
- - タイプ:`GradientType('linear' | 'radial')`
197
- - デフォルト:`linear`
198
-
199
- グラデーションの種類を指定します。
200
-
201
- ### `gradient-start-color`
202
-
203
- - タイプ:`string`
204
- - デフォルト:`#000000`
205
-
206
- グラデーションの開始色。
207
-
208
- ### `gradient-end-color`
209
-
210
- - タイプ:`string`
211
- - デフォルト:`#ffffff`
212
-
213
- グラデーションの終了色。
214
-
215
- ### `class`
216
-
217
- - タイプ:`string`
218
- - デフォルト:`''`
219
-
220
- QRコード要素のクラス名。
221
-
222
- ## `QrcodeVue` 3.5+
223
-
224
- `QrcodeVue` 3.5+ exports separate `QrcodeCanvas` and `QrcodeSvg` components, for which the rollup configuration has been modified:
225
-
226
- ```
227
- // rollup.config.js
228
-
229
- - exports: 'default',
230
- + exports: 'named',
231
- ```
232
-
233
- Direct references to `QrcodeVue` in common.js and cdn now require the `default` field:
234
-
235
- ```js
236
- const QrcodeVue = require('qrcode.vue').default
237
- const { default: QrcodeVue, QrcodeCanvas, QrcodeSvg } = require('qrcode.vue')
238
- ```
239
-
240
- ```html
241
- <!--With HTML-->
242
- <div id="root">
243
- <p class="flex space-x">
244
- <qrcode-vue :value="test" render-as="svg"></qrcode-vue>
245
- <qrcode-canvas :value="test"></qrcode-canvas>
246
- </p>
247
- <p><input v-model="test" /></p>
248
- </div>
249
- <script src="https://cdn.jsdelivr.net/npm/vue@3.5/dist/vue.global.prod.js"></script>
250
- <script src="https://cdn.jsdelivr.net/npm/qrcode.vue@3.5/dist/qrcode.vue.browser.min.js"></script>
251
-
252
- <script>
253
- Vue.createApp({
254
- data() { return {
255
- test: 'Hello World',
256
- }},
257
- components: {
258
- QrcodeVue: QrcodeVue.default,
259
- QrcodeCanvas: QrcodeVue.QrcodeCanvas,
260
- },
261
- }).mount('#root')
262
- </script>
263
- ```
264
-
265
- ## ライセンス
266
-
267
- copyright &copy; 2021 @scopewu, license by [MIT](https://github.com/scopewu/qrcode.vue/blob/main/LICENSE)
File without changes