qrcode.vue 3.5.1 → 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.
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * qrcode.vue v3.5.1
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.
@@ -20,7 +20,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
20
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
21
  PERFORMANCE OF THIS SOFTWARE.
22
22
  ***************************************************************************** */
23
- /* global Reflect, Promise, SuppressedError, Symbol */
23
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
24
24
 
25
25
 
26
26
  var __assign = function() {
@@ -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,13 +1073,34 @@ 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,
1027
1080
  required: false,
1028
1081
  default: function () { return ({}); },
1029
1082
  },
1083
+ gradient: {
1084
+ type: Boolean,
1085
+ required: false,
1086
+ default: false,
1087
+ },
1088
+ gradientType: {
1089
+ type: String,
1090
+ required: false,
1091
+ default: 'linear',
1092
+ validator: function (t) { return ['linear', 'radial'].indexOf(t) > -1; },
1093
+ },
1094
+ gradientStartColor: {
1095
+ type: String,
1096
+ required: false,
1097
+ default: '#000',
1098
+ },
1099
+ gradientEndColor: {
1100
+ type: String,
1101
+ required: false,
1102
+ default: '#fff',
1103
+ },
1030
1104
  };
1031
1105
  var QRCodeVueProps = __assign(__assign({}, QRCodeProps), { renderAs: {
1032
1106
  type: String,
@@ -1067,8 +1141,53 @@ var QrcodeSvg = defineComponent({
1067
1141
  // For level 40, 31329 -> 2
1068
1142
  fgPath.value = generatePath(cells, margin);
1069
1143
  };
1144
+ var renderGradient = function () {
1145
+ if (!props.gradient)
1146
+ return null;
1147
+ var gradientProps = props.gradientType === 'linear'
1148
+ ? {
1149
+ x1: '0%',
1150
+ y1: '0%',
1151
+ x2: '100%',
1152
+ y2: '100%',
1153
+ }
1154
+ : {
1155
+ cx: '50%',
1156
+ cy: '50%',
1157
+ r: '50%',
1158
+ fx: '50%',
1159
+ fy: '50%',
1160
+ };
1161
+ return h(props.gradientType === 'linear' ? 'linearGradient' : 'radialGradient', __assign({ id: 'qr-gradient' }, gradientProps), [
1162
+ h('stop', {
1163
+ offset: '0%',
1164
+ style: { stopColor: props.gradientStartColor },
1165
+ }),
1166
+ h('stop', {
1167
+ offset: '100%',
1168
+ style: { stopColor: props.gradientEndColor },
1169
+ }),
1170
+ ]);
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
+ };
1070
1189
  generate();
1071
- onUpdated(generate);
1190
+ watch(props, generate, { deep: true });
1072
1191
  return function () { return h('svg', {
1073
1192
  width: props.size,
1074
1193
  height: props.size,
@@ -1076,12 +1195,17 @@ var QrcodeSvg = defineComponent({
1076
1195
  xmlns: 'http://www.w3.org/2000/svg',
1077
1196
  viewBox: "0 0 ".concat(numCells.value, " ").concat(numCells.value),
1078
1197
  }, [
1079
- h('path', {
1198
+ h('defs', {}, [renderGradient(), renderClipPath()]),
1199
+ h('rect', {
1200
+ width: '100%',
1201
+ height: '100%',
1080
1202
  fill: props.background,
1081
- d: "M0,0 h".concat(numCells.value, "v").concat(numCells.value, "H0z"),
1082
1203
  }),
1083
- h('path', { fill: props.foreground, d: fgPath.value }),
1084
- props.imageSettings.src && h('image', __assign({ href: props.imageSettings.src }, imageProps)),
1204
+ h('path', {
1205
+ fill: props.gradient ? 'url(#qr-gradient)' : props.foreground,
1206
+ d: fgPath.value,
1207
+ }),
1208
+ props.imageSettings.src && h('image', __assign(__assign({ href: props.imageSettings.src }, imageProps), (props.imageSettings.borderRadius ? { 'clip-path': 'url(#qr-logo-clip)' } : {}))),
1085
1209
  ]); };
1086
1210
  },
1087
1211
  });
@@ -1092,7 +1216,7 @@ var QrcodeCanvas = defineComponent({
1092
1216
  var canvasEl = ref(null);
1093
1217
  var imageRef = ref(null);
1094
1218
  var generate = function () {
1095
- var value = props.value, _level = props.level, size = props.size, _margin = props.margin, background = props.background, foreground = props.foreground;
1219
+ var value = props.value, _level = props.level, size = props.size, _margin = props.margin, background = props.background, foreground = props.foreground, gradient = props.gradient, gradientType = props.gradientType, gradientStartColor = props.gradientStartColor, gradientEndColor = props.gradientEndColor;
1096
1220
  var margin = _margin >>> 0;
1097
1221
  var level = validErrorCorrectLevel(_level) ? _level : defaultErrorCorrectLevel;
1098
1222
  var canvas = canvasEl.value;
@@ -1120,13 +1244,27 @@ var QrcodeCanvas = defineComponent({
1120
1244
  cells = excavateModules(cells, imageSettings.excavation);
1121
1245
  }
1122
1246
  }
1123
- var devicePixelRatio = window.devicePixelRatio || 1;
1247
+ var devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
1124
1248
  var scale = (size / numCells) * devicePixelRatio;
1125
1249
  canvas.height = canvas.width = size * devicePixelRatio;
1126
1250
  ctx.scale(scale, scale);
1127
1251
  ctx.fillStyle = background;
1128
1252
  ctx.fillRect(0, 0, numCells, numCells);
1129
- ctx.fillStyle = foreground;
1253
+ if (gradient) {
1254
+ var grad = void 0;
1255
+ if (gradientType === 'linear') {
1256
+ grad = ctx.createLinearGradient(0, 0, numCells, numCells);
1257
+ }
1258
+ else {
1259
+ grad = ctx.createRadialGradient(numCells / 2, numCells / 2, 0, numCells / 2, numCells / 2, numCells / 2);
1260
+ }
1261
+ grad.addColorStop(0, gradientStartColor);
1262
+ grad.addColorStop(1, gradientEndColor);
1263
+ ctx.fillStyle = grad;
1264
+ }
1265
+ else {
1266
+ ctx.fillStyle = foreground;
1267
+ }
1130
1268
  if (SUPPORTS_PATH2D) {
1131
1269
  ctx.fill(new Path2D(generatePath(cells, margin)));
1132
1270
  }
@@ -1140,11 +1278,28 @@ var QrcodeCanvas = defineComponent({
1140
1278
  });
1141
1279
  }
1142
1280
  if (showImage) {
1143
- 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
+ }
1144
1299
  }
1145
1300
  };
1146
1301
  onMounted(generate);
1147
- onUpdated(generate);
1302
+ watch(props, generate, { deep: true });
1148
1303
  var style = ctx.attrs.style;
1149
1304
  return function () { return h(Fragment, [
1150
1305
  h('canvas', __assign(__assign({}, ctx.attrs), { ref: canvasEl, style: __assign(__assign({}, style), { width: "".concat(props.size, "px"), height: "".concat(props.size, "px") }) })),
@@ -1160,8 +1315,20 @@ var QrcodeCanvas = defineComponent({
1160
1315
  var QrcodeVue = defineComponent({
1161
1316
  name: 'Qrcode',
1162
1317
  render: function () {
1163
- var _a = this.$props, renderAs = _a.renderAs, value = _a.value, size = _a.size, margin = _a.margin, level = _a.level, background = _a.background, foreground = _a.foreground, imageSettings = _a.imageSettings;
1164
- return h(renderAs === 'svg' ? QrcodeSvg : QrcodeCanvas, { value: value, size: size, margin: margin, level: level, background: background, foreground: foreground, imageSettings: imageSettings });
1318
+ var _a = this.$props, renderAs = _a.renderAs, value = _a.value, size = _a.size, margin = _a.margin, level = _a.level, background = _a.background, foreground = _a.foreground, imageSettings = _a.imageSettings, gradient = _a.gradient, gradientType = _a.gradientType, gradientStartColor = _a.gradientStartColor, gradientEndColor = _a.gradientEndColor;
1319
+ return h(renderAs === 'svg' ? QrcodeSvg : QrcodeCanvas, {
1320
+ value: value,
1321
+ size: size,
1322
+ margin: margin,
1323
+ level: level,
1324
+ background: background,
1325
+ foreground: foreground,
1326
+ imageSettings: imageSettings,
1327
+ gradient: gradient,
1328
+ gradientType: gradientType,
1329
+ gradientStartColor: gradientStartColor,
1330
+ gradientEndColor: gradientEndColor,
1331
+ });
1165
1332
  },
1166
1333
  props: QRCodeVueProps,
1167
1334
  });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@rstest/core").RstestConfig;
2
+ export default _default;
@@ -1,6 +1,7 @@
1
1
  import { PropType } from 'vue';
2
2
  export type Level = 'L' | 'M' | 'Q' | 'H';
3
3
  export type RenderAs = 'canvas' | 'svg';
4
+ export type GradientType = 'linear' | 'radial';
4
5
  export type ImageSettings = {
5
6
  src: string;
6
7
  x?: number;
@@ -8,6 +9,7 @@ export type ImageSettings = {
8
9
  height: number;
9
10
  width: number;
10
11
  excavate?: boolean;
12
+ borderRadius?: number;
11
13
  };
12
14
  export declare const QrcodeSvg: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
13
15
  value: {
@@ -42,6 +44,27 @@ export declare const QrcodeSvg: import("vue").DefineComponent<import("vue").Extr
42
44
  required: boolean;
43
45
  default: () => {};
44
46
  };
47
+ gradient: {
48
+ type: BooleanConstructor;
49
+ required: boolean;
50
+ default: boolean;
51
+ };
52
+ gradientType: {
53
+ type: PropType<GradientType>;
54
+ required: boolean;
55
+ default: string;
56
+ validator: (t: any) => boolean;
57
+ };
58
+ gradientStartColor: {
59
+ type: StringConstructor;
60
+ required: boolean;
61
+ default: string;
62
+ };
63
+ gradientEndColor: {
64
+ type: StringConstructor;
65
+ required: boolean;
66
+ default: string;
67
+ };
45
68
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
46
69
  [key: string]: any;
47
70
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -77,6 +100,27 @@ export declare const QrcodeSvg: import("vue").DefineComponent<import("vue").Extr
77
100
  required: boolean;
78
101
  default: () => {};
79
102
  };
103
+ gradient: {
104
+ type: BooleanConstructor;
105
+ required: boolean;
106
+ default: boolean;
107
+ };
108
+ gradientType: {
109
+ type: PropType<GradientType>;
110
+ required: boolean;
111
+ default: string;
112
+ validator: (t: any) => boolean;
113
+ };
114
+ gradientStartColor: {
115
+ type: StringConstructor;
116
+ required: boolean;
117
+ default: string;
118
+ };
119
+ gradientEndColor: {
120
+ type: StringConstructor;
121
+ required: boolean;
122
+ default: string;
123
+ };
80
124
  }>> & Readonly<{}>, {
81
125
  value: string;
82
126
  size: number;
@@ -85,6 +129,10 @@ export declare const QrcodeSvg: import("vue").DefineComponent<import("vue").Extr
85
129
  foreground: string;
86
130
  margin: number;
87
131
  imageSettings: ImageSettings;
132
+ gradient: boolean;
133
+ gradientType: GradientType;
134
+ gradientStartColor: string;
135
+ gradientEndColor: string;
88
136
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
89
137
  export declare const QrcodeCanvas: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
90
138
  value: {
@@ -119,6 +167,27 @@ export declare const QrcodeCanvas: import("vue").DefineComponent<import("vue").E
119
167
  required: boolean;
120
168
  default: () => {};
121
169
  };
170
+ gradient: {
171
+ type: BooleanConstructor;
172
+ required: boolean;
173
+ default: boolean;
174
+ };
175
+ gradientType: {
176
+ type: PropType<GradientType>;
177
+ required: boolean;
178
+ default: string;
179
+ validator: (t: any) => boolean;
180
+ };
181
+ gradientStartColor: {
182
+ type: StringConstructor;
183
+ required: boolean;
184
+ default: string;
185
+ };
186
+ gradientEndColor: {
187
+ type: StringConstructor;
188
+ required: boolean;
189
+ default: string;
190
+ };
122
191
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
123
192
  [key: string]: any;
124
193
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -154,6 +223,27 @@ export declare const QrcodeCanvas: import("vue").DefineComponent<import("vue").E
154
223
  required: boolean;
155
224
  default: () => {};
156
225
  };
226
+ gradient: {
227
+ type: BooleanConstructor;
228
+ required: boolean;
229
+ default: boolean;
230
+ };
231
+ gradientType: {
232
+ type: PropType<GradientType>;
233
+ required: boolean;
234
+ default: string;
235
+ validator: (t: any) => boolean;
236
+ };
237
+ gradientStartColor: {
238
+ type: StringConstructor;
239
+ required: boolean;
240
+ default: string;
241
+ };
242
+ gradientEndColor: {
243
+ type: StringConstructor;
244
+ required: boolean;
245
+ default: string;
246
+ };
157
247
  }>> & Readonly<{}>, {
158
248
  value: string;
159
249
  size: number;
@@ -162,6 +252,10 @@ export declare const QrcodeCanvas: import("vue").DefineComponent<import("vue").E
162
252
  foreground: string;
163
253
  margin: number;
164
254
  imageSettings: ImageSettings;
255
+ gradient: boolean;
256
+ gradientType: GradientType;
257
+ gradientStartColor: string;
258
+ gradientEndColor: string;
165
259
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
166
260
  declare const QrcodeVue: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
167
261
  renderAs: {
@@ -202,6 +296,27 @@ declare const QrcodeVue: import("vue").DefineComponent<import("vue").ExtractProp
202
296
  required: boolean;
203
297
  default: () => {};
204
298
  };
299
+ gradient: {
300
+ type: BooleanConstructor;
301
+ required: boolean;
302
+ default: boolean;
303
+ };
304
+ gradientType: {
305
+ type: PropType<GradientType>;
306
+ required: boolean;
307
+ default: string;
308
+ validator: (t: any) => boolean;
309
+ };
310
+ gradientStartColor: {
311
+ type: StringConstructor;
312
+ required: boolean;
313
+ default: string;
314
+ };
315
+ gradientEndColor: {
316
+ type: StringConstructor;
317
+ required: boolean;
318
+ default: string;
319
+ };
205
320
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
206
321
  renderAs: {
207
322
  type: PropType<RenderAs>;
@@ -241,6 +356,27 @@ declare const QrcodeVue: import("vue").DefineComponent<import("vue").ExtractProp
241
356
  required: boolean;
242
357
  default: () => {};
243
358
  };
359
+ gradient: {
360
+ type: BooleanConstructor;
361
+ required: boolean;
362
+ default: boolean;
363
+ };
364
+ gradientType: {
365
+ type: PropType<GradientType>;
366
+ required: boolean;
367
+ default: string;
368
+ validator: (t: any) => boolean;
369
+ };
370
+ gradientStartColor: {
371
+ type: StringConstructor;
372
+ required: boolean;
373
+ default: string;
374
+ };
375
+ gradientEndColor: {
376
+ type: StringConstructor;
377
+ required: boolean;
378
+ default: string;
379
+ };
244
380
  }>> & Readonly<{}>, {
245
381
  value: string;
246
382
  size: number;
@@ -249,6 +385,10 @@ declare const QrcodeVue: import("vue").DefineComponent<import("vue").ExtractProp
249
385
  foreground: string;
250
386
  margin: number;
251
387
  imageSettings: ImageSettings;
388
+ gradient: boolean;
389
+ gradientType: GradientType;
390
+ gradientStartColor: string;
391
+ gradientEndColor: string;
252
392
  renderAs: RenderAs;
253
393
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
254
394
  export default QrcodeVue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qrcode.vue",
3
- "version": "3.5.1",
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,10 +49,13 @@
48
49
  "dependencies": {},
49
50
  "devDependencies": {
50
51
  "@rollup/plugin-terser": "^0.4.4",
51
- "@rsbuild/core": "^1.0.14",
52
- "rollup": "^4.24.0",
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",
53
57
  "rollup-plugin-typescript2": "^0.36.0",
54
- "typescript": "^5.6.3",
55
- "vue": "^3.5.12"
58
+ "typescript": "^5.9.3",
59
+ "vue": "^3.5.27"
56
60
  }
57
61
  }