qrcode.vue 3.9.0 → 3.9.1
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/CHANGELOG.md +10 -0
- package/README-zh_cn.md +38 -16
- package/README.md +38 -16
- package/dist/{src/index.d.ts → index.d.ts} +24 -0
- package/dist/qrcode.vue.browser.js +11 -7
- package/dist/qrcode.vue.browser.min.js +2 -2
- package/dist/qrcode.vue.cjs.js +11 -7
- package/dist/qrcode.vue.esm.js +12 -8
- package/package.json +8 -8
- package/dist/rstest.config.d.ts +0 -2
- package/dist/src/qrcodegen.d.ts +0 -95
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [3.9.1]
|
|
2
|
+
|
|
3
|
+
### Bugfix
|
|
4
|
+
|
|
5
|
+
- Remove static `useId` import to fix build errors for Vue < 3.5 (`No matching export for import "useId"`).
|
|
6
|
+
|
|
7
|
+
### Feature
|
|
8
|
+
|
|
9
|
+
- Add `id` prop for SSR hydration consistency. Pass `useId()` to ensure matching IDs between server and client.
|
|
10
|
+
|
|
1
11
|
## [3.9.0]
|
|
2
12
|
|
|
3
13
|
### Feature
|
package/README-zh_cn.md
CHANGED
|
@@ -189,6 +189,44 @@ createApp({
|
|
|
189
189
|
|
|
190
190
|
二维码图片 logo 配置。
|
|
191
191
|
|
|
192
|
+
### `radius`
|
|
193
|
+
|
|
194
|
+
- 类型:`number`
|
|
195
|
+
- 默认值:`0`
|
|
196
|
+
|
|
197
|
+
每个二维码模块的圆角半径,相对于模块宽度的比例。接受 `0` 到 `0.5` 的值。
|
|
198
|
+
|
|
199
|
+
- `0`(默认)- 方形模块,直角
|
|
200
|
+
- `0.5` - 最大圆角,模块变为圆形
|
|
201
|
+
|
|
202
|
+
圆角是上下文感知的:相邻深色模块之间的内角保持直角,外角则圆角化。
|
|
203
|
+
|
|
204
|
+
```html
|
|
205
|
+
<qrcode-vue value="test" :radius="0.35" />
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `id`
|
|
209
|
+
|
|
210
|
+
- 类型:`string`
|
|
211
|
+
- 默认值:`undefined`
|
|
212
|
+
|
|
213
|
+
自定义 SVG 内部元素(渐变、裁剪路径)的 ID。SSR 水合一致性需要此属性 — 传入 `useId()` 以确保服务端和客户端生成匹配的 ID。
|
|
214
|
+
|
|
215
|
+
```html
|
|
216
|
+
<script setup>
|
|
217
|
+
// 仅 vue 3.5+
|
|
218
|
+
import { useId } from 'vue'
|
|
219
|
+
const uid = useId()
|
|
220
|
+
|
|
221
|
+
// vue 3.4 及以下版本
|
|
222
|
+
// const uid = 'qrcode-1'
|
|
223
|
+
// const uid2 = 'qrcode-2'
|
|
224
|
+
</script>
|
|
225
|
+
<qrcode-svg value="test" :id="uid" render-as="svg" />
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
省略时使用模块级计数器,该计数器在多请求的 SSR 环境中不安全。
|
|
229
|
+
|
|
192
230
|
### `gradient`
|
|
193
231
|
|
|
194
232
|
- 类型: `boolean`
|
|
@@ -217,22 +255,6 @@ createApp({
|
|
|
217
255
|
|
|
218
256
|
渐变的结束颜色。
|
|
219
257
|
|
|
220
|
-
### `radius`
|
|
221
|
-
|
|
222
|
-
- 类型:`number`
|
|
223
|
-
- 默认值:`0`
|
|
224
|
-
|
|
225
|
-
每个二维码模块的圆角半径,相对于模块宽度的比例。接受 `0` 到 `0.5` 的值。
|
|
226
|
-
|
|
227
|
-
- `0`(默认)- 方形模块,直角
|
|
228
|
-
- `0.5` - 最大圆角,模块变为圆形
|
|
229
|
-
|
|
230
|
-
圆角是上下文感知的:相邻深色模块之间的内角保持直角,外角则圆角化。
|
|
231
|
-
|
|
232
|
-
```html
|
|
233
|
-
<qrcode-vue value="test" :radius="0.35" />
|
|
234
|
-
```
|
|
235
|
-
|
|
236
258
|
### `class`
|
|
237
259
|
|
|
238
260
|
- 类型:`string`
|
package/README.md
CHANGED
|
@@ -187,6 +187,44 @@ The foreground color of qrcode.
|
|
|
187
187
|
|
|
188
188
|
The settings to support qrcode image logo.
|
|
189
189
|
|
|
190
|
+
### `radius`
|
|
191
|
+
|
|
192
|
+
- Type: `number`
|
|
193
|
+
- Default: `0`
|
|
194
|
+
|
|
195
|
+
The corner radius of each QR module, as a ratio of the module width. Accepts values from `0` to `0.5`.
|
|
196
|
+
|
|
197
|
+
- `0` (default) - square modules with sharp corners
|
|
198
|
+
- `0.5` - maximum rounding, modules become circles
|
|
199
|
+
|
|
200
|
+
The rounding is context-aware: inner corners between adjacent dark modules remain sharp, while outer corners are rounded.
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<qrcode-vue value="test" :radius="0.35" />
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### `id`
|
|
207
|
+
|
|
208
|
+
- Type: `string`
|
|
209
|
+
- Default: `undefined`
|
|
210
|
+
|
|
211
|
+
Custom ID for SVG internal elements (gradients, clip-paths). Required for SSR hydration consistency — pass `useId()` to ensure server and client generate matching IDs.
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<script setup>
|
|
215
|
+
// vue 3.5+ only
|
|
216
|
+
import { useId } from 'vue'
|
|
217
|
+
const uid = useId()
|
|
218
|
+
|
|
219
|
+
// older vue versions (3.4 and below)
|
|
220
|
+
// const uid = 'qrcode-1'
|
|
221
|
+
// const uid2 = 'qrcode-2'
|
|
222
|
+
</script>
|
|
223
|
+
<qrcode-svg value="test" :id="uid" render-as="svg" />
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
When omitted, a module-level counter is used, which is not SSR-safe across multiple requests.
|
|
227
|
+
|
|
190
228
|
### `gradient`
|
|
191
229
|
|
|
192
230
|
- Type: `boolean`
|
|
@@ -215,22 +253,6 @@ The start color of the gradient.
|
|
|
215
253
|
|
|
216
254
|
The end color of the gradient.
|
|
217
255
|
|
|
218
|
-
### `radius`
|
|
219
|
-
|
|
220
|
-
- Type: `number`
|
|
221
|
-
- Default: `0`
|
|
222
|
-
|
|
223
|
-
The corner radius of each QR module, as a ratio of the module width. Accepts values from `0` to `0.5`.
|
|
224
|
-
|
|
225
|
-
- `0` (default) - square modules with sharp corners
|
|
226
|
-
- `0.5` - maximum rounding, modules become circles
|
|
227
|
-
|
|
228
|
-
The rounding is context-aware: inner corners between adjacent dark modules remain sharp, while outer corners are rounded.
|
|
229
|
-
|
|
230
|
-
```html
|
|
231
|
-
<qrcode-vue value="test" :radius="0.35" />
|
|
232
|
-
```
|
|
233
|
-
|
|
234
256
|
### `class`
|
|
235
257
|
|
|
236
258
|
- Type: `string`
|
|
@@ -71,6 +71,10 @@ export declare const QrcodeSvg: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
71
71
|
default: number;
|
|
72
72
|
validator: (r: any) => boolean;
|
|
73
73
|
};
|
|
74
|
+
id: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
required: boolean;
|
|
77
|
+
};
|
|
74
78
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
75
79
|
[key: string]: any;
|
|
76
80
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
|
@@ -133,6 +137,10 @@ export declare const QrcodeSvg: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
133
137
|
default: number;
|
|
134
138
|
validator: (r: any) => boolean;
|
|
135
139
|
};
|
|
140
|
+
id: {
|
|
141
|
+
type: StringConstructor;
|
|
142
|
+
required: boolean;
|
|
143
|
+
};
|
|
136
144
|
}>> & Readonly<{}>, {
|
|
137
145
|
value: string;
|
|
138
146
|
size: number;
|
|
@@ -207,6 +215,10 @@ export declare const QrcodeCanvas: import("vue").DefineComponent<ExtractPropType
|
|
|
207
215
|
default: number;
|
|
208
216
|
validator: (r: any) => boolean;
|
|
209
217
|
};
|
|
218
|
+
id: {
|
|
219
|
+
type: StringConstructor;
|
|
220
|
+
required: boolean;
|
|
221
|
+
};
|
|
210
222
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
211
223
|
[key: string]: any;
|
|
212
224
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
|
@@ -269,6 +281,10 @@ export declare const QrcodeCanvas: import("vue").DefineComponent<ExtractPropType
|
|
|
269
281
|
default: number;
|
|
270
282
|
validator: (r: any) => boolean;
|
|
271
283
|
};
|
|
284
|
+
id: {
|
|
285
|
+
type: StringConstructor;
|
|
286
|
+
required: boolean;
|
|
287
|
+
};
|
|
272
288
|
}>> & Readonly<{}>, {
|
|
273
289
|
value: string;
|
|
274
290
|
size: number;
|
|
@@ -349,6 +365,10 @@ declare const QrcodeVue: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
349
365
|
default: number;
|
|
350
366
|
validator: (r: any) => boolean;
|
|
351
367
|
};
|
|
368
|
+
id: {
|
|
369
|
+
type: StringConstructor;
|
|
370
|
+
required: boolean;
|
|
371
|
+
};
|
|
352
372
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
353
373
|
[key: string]: any;
|
|
354
374
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
|
@@ -417,6 +437,10 @@ declare const QrcodeVue: import("vue").DefineComponent<ExtractPropTypes<{
|
|
|
417
437
|
default: number;
|
|
418
438
|
validator: (r: any) => boolean;
|
|
419
439
|
};
|
|
440
|
+
id: {
|
|
441
|
+
type: StringConstructor;
|
|
442
|
+
required: boolean;
|
|
443
|
+
};
|
|
420
444
|
}>> & Readonly<{}>, {
|
|
421
445
|
value: string;
|
|
422
446
|
size: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* qrcode.vue v3.9.
|
|
2
|
+
* qrcode.vue v3.9.1
|
|
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,11 +910,10 @@ var qrcodegen;
|
|
|
910
910
|
var QR = qrcodegen;
|
|
911
911
|
|
|
912
912
|
var _uid = 0;
|
|
913
|
-
function getUid() {
|
|
914
|
-
if (
|
|
915
|
-
return
|
|
916
|
-
|
|
917
|
-
return "vue-".concat(Math.random().toString(36).slice(2), "-").concat(_uid++);
|
|
913
|
+
function getUid(id) {
|
|
914
|
+
if (id)
|
|
915
|
+
return id;
|
|
916
|
+
return "v-".concat(_uid++);
|
|
918
917
|
}
|
|
919
918
|
var defaultErrorCorrectLevel = 'L';
|
|
920
919
|
var DEFAULT_QR_SIZE = 100;
|
|
@@ -1134,6 +1133,10 @@ var QRCodeProps = {
|
|
|
1134
1133
|
default: 0,
|
|
1135
1134
|
validator: function (r) { return !isNaN(r) && r >= 0 && r <= 0.5; },
|
|
1136
1135
|
},
|
|
1136
|
+
id: {
|
|
1137
|
+
type: String,
|
|
1138
|
+
required: false,
|
|
1139
|
+
},
|
|
1137
1140
|
};
|
|
1138
1141
|
var QRCodeVueProps = __assign(__assign({}, QRCodeProps), { renderAs: {
|
|
1139
1142
|
type: String,
|
|
@@ -1146,7 +1149,7 @@ var QrcodeSvg = vue.defineComponent({
|
|
|
1146
1149
|
props: QRCodeProps,
|
|
1147
1150
|
setup: function (props) {
|
|
1148
1151
|
var _a = useQRCode(props), numCells = _a.numCells, fgPath = _a.fgPath, imageProps = _a.imageProps, imageBorderProps = _a.imageBorderProps;
|
|
1149
|
-
var uid = getUid();
|
|
1152
|
+
var uid = getUid(props.id);
|
|
1150
1153
|
var qrGradientId = "qrcode.vue-gradient-".concat(uid);
|
|
1151
1154
|
var qrLogoClipPathId = "qrcode.vue-logo-clip-path-".concat(uid);
|
|
1152
1155
|
var gradientVNode = vue.computed(function () {
|
|
@@ -1336,6 +1339,7 @@ var QrcodeVue = vue.defineComponent({
|
|
|
1336
1339
|
gradientStartColor: props.gradientStartColor,
|
|
1337
1340
|
gradientEndColor: props.gradientEndColor,
|
|
1338
1341
|
radius: props.radius,
|
|
1342
|
+
id: props.id,
|
|
1339
1343
|
}); };
|
|
1340
1344
|
},
|
|
1341
1345
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* qrcode.vue v3.9.
|
|
2
|
+
* qrcode.vue v3.9.1
|
|
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,a){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>a||a>7)throw new RangeError("Mask value out of range");this.size=4*e+17;for(var i=[],u=0;this.size>u;u++)i.push(!1);for(u=0;this.size>u;u++)this.modules.push(i.slice()),this.isFunction.push(i.slice());this.drawFunctionPatterns();var s=this.addEccAndInterleave(n);if(this.drawCodewords(s),-1==a){var l=1e9;for(u=0;8>u;u++){this.applyMask(u),this.drawFormatBits(u);var c=this.getPenaltyScore();l>c&&(a=u,l=c),this.applyMask(u)}}o(a>=0&&7>=a),this.mask=a,this.applyMask(a),this.drawFormatBits(a),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,i,u,s,l){if(void 0===i&&(i=1),void 0===u&&(u=40),void 0===s&&(s=-1),void 0===l&&(l=!0),t.MIN_VERSION>i||i>u||u>t.MAX_VERSION||-1>s||s>7)throw new RangeError("Invalid value");var c,d;for(c=i;;c++){var h=8*t.getNumDataCodewords(c,n),f=a.getTotalBits(e,c);if(h>=f){d=f;break}if(c>=u)throw new RangeError("Data too long")}for(var v=0,g=[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH];g.length>v;v++){var p=g[v];l&&d<=8*t.getNumDataCodewords(c,p)&&(n=p)}for(var m=[],y=0,w=e;w.length>y;y++){var E=w[y];r(E.mode.modeBits,4,m),r(E.numChars,E.mode.numCharCountBits(c),m);for(var C=0,M=E.getData();M.length>C;C++){m.push(M[C])}}o(m.length==d);var R=8*t.getNumDataCodewords(c,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 A=[];m.length>8*A.length;)A.push(0);return m.forEach(function(e,t){return A[t>>>3]|=e<<7-(7&t)}),new t(c,n,A,s)},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,a=0;10>a;a++)r=r<<1^1335*(r>>>9);var i=21522^(t<<10|r);o(i>>>15==0);for(a=0;5>=a;a++)this.setFunctionModule(8,a,n(i,a));this.setFunctionModule(8,7,n(i,6)),this.setFunctionModule(8,8,n(i,7)),this.setFunctionModule(7,8,n(i,8));for(a=9;15>a;a++)this.setFunctionModule(14-a,8,n(i,a));for(a=0;8>a;a++)this.setFunctionModule(this.size-1-a,8,n(i,a));for(a=8;15>a;a++)this.setFunctionModule(8,this.size-15+a,n(i,a));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 a=n(r,t),i=this.size-11+t%3,u=Math.floor(t/3);this.setFunctionModule(i,u,a),this.setFunctionModule(u,i,a)}}},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)),a=e+n,i=t+r;a>=0&&this.size>a&&i>=0&&this.size>i&&this.setFunctionModule(a,i,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 a=t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r],i=t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r],u=Math.floor(t.getNumRawDataModules(r)/8),s=a-u%a,l=Math.floor(u/a),c=[],d=t.reedSolomonComputeDivisor(i),h=0,f=0;a>h;h++){var v=e.slice(f,f+l-i+(s>h?0:1));f+=v.length;var g=t.reedSolomonComputeRemainder(v,d);s>h&&v.push(0),c.push(v.concat(g))}var p=[],m=function(e){c.forEach(function(t,r){e==l-i&&s>r||p.push(t[e])})};for(h=0;c[0].length>h;h++)m(h);return o(p.length==u),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,a=this.size-1;a>=1;a-=2){6==a&&(a=5);for(var i=0;this.size>i;i++)for(var u=0;2>u;u++){var s=a-u,l=!(a+1&2)?this.size-1-i:i;!this.isFunction[l][s]&&8*e.length>r&&(this.modules[l][s]=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,a=0,i=[0,0,0,0,0,0,0],u=0;this.size>u;u++)this.modules[r][u]==n?5==++a?e+=t.PENALTY_N1:a>5&&e++:(this.finderPenaltyAddHistory(a,i),n||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),n=this.modules[r][u],a=1);e+=this.finderPenaltyTerminateAndCount(n,a,i)*t.PENALTY_N3}for(u=0;this.size>u;u++){n=!1;var s=0;for(i=[0,0,0,0,0,0,0],r=0;this.size>r;r++)this.modules[r][u]==n?5==++s?e+=t.PENALTY_N1:s>5&&e++:(this.finderPenaltyAddHistory(s,i),n||(e+=this.finderPenaltyCountPatterns(i)*t.PENALTY_N3),n=this.modules[r][u],s=1);e+=this.finderPenaltyTerminateAndCount(n,s,i)*t.PENALTY_N3}for(r=0;this.size-1>r;r++)for(u=0;this.size-1>u;u++){var l=this.modules[r][u];l==this.modules[r][u+1]&&l==this.modules[r+1][u]&&l==this.modules[r+1][u+1]&&(e+=t.PENALTY_N2)}for(var c=0,d=0,h=this.modules;h.length>d;d++){c=h[d].reduce(function(e,t){return e+(t?1:0)},c)}var f=this.size*this.size,v=Math.ceil(Math.abs(20*c-10*f)/f)-1;return o(v>=0&&9>=v),o((e+=v*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 a=0;r.length>a;a++)r[a]=t.reedSolomonMultiply(r[a],o),r.length>a+1&&(r[a]^=r[a+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)})},a=0,i=e;i.length>a;a++){o(i[a])}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 a=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,a=t;a.length>o;o++){r(a[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 a=Math.min(t.length-o,3);r(parseInt(t.substring(o,o+a),10),3*a+1,n),o+=a}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 a=45*e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n));r(a+=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 a=o[n],i=a.mode.numCharCountBits(t);if(a.numChars>=1<<i)return 1/0;r+=4+i+a.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=a}(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,a=0;var i={L:o.QrCode.Ecc.LOW,M:o.QrCode.Ecc.MEDIUM,Q:o.QrCode.Ecc.QUARTILE,H:o.QrCode.Ecc.HIGH},u=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();function s(e){return e in i}function l(e,t,r){var n=t>0&&e[t-1][r],o=e.length-1>t&&e[t+1][r],a=r>0&&e[t][r-1],i=e[t].length-1>r&&e[t][r+1];return{nw:!n&&!a,ne:!n&&!i,se:!o&&!i,sw:!o&&!a}}function c(e){var r=t.computed(function(){var t;return(null!==(t=e.margin)&&void 0!==t?t:0)>>>0}),n=t.computed(function(){var t=s(e.level)?e.level:"L";return o.QrCode.encodeText(e.value,i[t]).getModules()}),a=t.computed(function(){return n.value.length+2*r.value}),u=t.computed(function(){return e.radius>0?function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);for(var n=[],o=Math.min(r,.5),a=0;e.length>a;a++)for(var i=0;e[a].length>i;i++)if(e[a][i]){var u=l(e,a,i),s=u.nw,c=u.ne,d=u.se,h=u.sw,f=i+t,v=a+t;n.push("M".concat(f+(s?o:0)," ").concat(v),"L".concat(f+1-(c?o:0)," ").concat(v)),c&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f+1," ").concat(v+o)),n.push("L".concat(f+1," ").concat(v+1-(d?o:0))),d&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f+1-o," ").concat(v+1)),n.push("L".concat(f+(h?o:0)," ").concat(v+1)),h&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f," ").concat(v+1-o)),n.push("L".concat(f," ").concat(v+(s?o:0))),s&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f+o," ").concat(v)),n.push("z")}return n.join("")}(n.value,r.value,e.radius):function(e,t){void 0===t&&(t=0);for(var r=[],n=0;e.length>n;n++)for(var o=e[n],a=null,i=0;o.length>i;i++){var u=o[i];if(u||null===a)if(i!==o.length-1)u&&null===a&&(a=i);else{if(!u)continue;r.push(null===a?"M".concat(i+t,",").concat(n+t," h1v1H").concat(i+t,"z"):"M".concat(a+t,",").concat(n+t," h").concat(i+1-a,"v1H").concat(a+t,"z"))}else r.push("M".concat(a+t," ").concat(n+t,"h").concat(i-a,"v1H").concat(a+t,"z")),a=null}return r.join("")}(n.value,r.value)}),c=t.computed(function(){if(!e.imageSettings.src)return null;var t=function(e,t,r,n){var o=n.width,a=n.height,i=n.x,u=n.y,s=e.length+2*r,l=Math.floor(.1*t),c=s/t,d=(o||l)*c,h=(a||l)*c;return{x:null==i?e.length/2-d/2:i*c,y:null==u?e.length/2-h/2:u*c,h:h,w:d,borderRadius:(n.borderRadius||0)*c}}(n.value,e.size,r.value,e.imageSettings);return{x:t.x+r.value,y:t.y+r.value,width:t.w,height:t.h,borderRadius:t.borderRadius}}),d=t.computed(function(){if(!e.imageSettings.excavate||!c.value)return null;var t=2/(e.size/a.value);return{x:c.value.x-t,y:c.value.y-t,width:c.value.width+2*t,height:c.value.height+2*t,borderRadius:c.value.borderRadius}});return{margin:r,numCells:a,cells:n,fgPath:u,imageProps:c,imageBorderProps:d}}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"},radius:{type:Number,required:!1,default:0,validator:function(e){return!isNaN(e)&&e>=0&&.5>=e}}},h=n(n({},d),{renderAs:{type:String,required:!1,default:"canvas",validator:function(e){return["canvas","svg"].indexOf(e)>-1}}}),f=t.defineComponent({name:"QRCodeSvg",props:d,setup:function(e){var r=c(e),o=r.numCells,i=r.fgPath,u=r.imageProps,s=r.imageBorderProps,l="function"==typeof t.useId?"".concat(t.useId(),"-").concat(a++):"vue-".concat(Math.random().toString(36).slice(2),"-").concat(a++),d="qrcode.vue-gradient-".concat(l),h="qrcode.vue-logo-clip-path-".concat(l),f=t.computed(function(){return e.gradient?t.h("linear"===e.gradientType?"linearGradient":"radialGradient",n({id:d},"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}),v=t.computed(function(){if(!u.value)return null;var e=u.value.borderRadius;return e>0?t.h("clipPath",{id:h},[t.h("rect",{x:u.value.x,y:u.value.y,width:u.value.width,height:u.value.height,rx:e,ry:e})]):null});return function(){return t.h("svg",{width:e.size,height:e.size,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(o.value," ").concat(o.value),role:"img","aria-label":e.value},[t.h("defs",{},[f.value,v.value]),t.h("rect",{width:"100%",height:"100%",fill:e.background}),t.h("path",{fill:e.gradient?"url(#".concat(d,")"):e.foreground,d:i.value}),s.value&&t.h("rect",{x:s.value.x,y:s.value.y,width:s.value.width,height:s.value.height,fill:e.background,rx:s.value.borderRadius,ry:s.value.borderRadius}),e.imageSettings.src&&u.value&&t.h("image",n(n({href:e.imageSettings.src},u.value),u.value.borderRadius>0?{"clip-path":"url(#".concat(h,")")}:{}))])}}}),v=t.defineComponent({name:"QRCodeCanvas",props:d,setup:function(e,r){var o=c(e),a=o.margin,i=o.cells,s=o.numCells,l=o.fgPath,d=o.imageProps,h=o.imageBorderProps,f=t.ref(null),v=t.ref(null),g=function(e,t,r,n,o,a){e.beginPath(),e.roundRect?e.roundRect(t,r,n,o,a):e.rect(t,r,n,o)},p=function(){var t=e.size,r=e.background,n=e.foreground,o=e.gradient,c=e.gradientType,p=e.gradientStartColor,m=e.gradientEndColor,y=f.value;if(y){var w=y.getContext("2d");if(w){var E=v.value,C="undefined"!=typeof window&&window.devicePixelRatio||1,M=t/s.value*C;if(y.height=y.width=t*C,w.setTransform(M,0,0,M,0,0),w.fillStyle=r,w.fillRect(0,0,s.value,s.value),o){var R=void 0;(R="linear"===c?w.createLinearGradient(0,0,s.value,s.value):w.createRadialGradient(s.value/2,s.value/2,0,s.value/2,s.value/2,s.value/2)).addColorStop(0,p),R.addColorStop(1,m),w.fillStyle=R}else w.fillStyle=n;if(u?w.fill(new Path2D(l.value)):i.value.forEach(function(e,t){e.forEach(function(e,r){e&&w.fillRect(r+a.value,t+a.value,1,1)})}),e.imageSettings.src&&E&&0!==E.naturalWidth&&0!==E.naturalHeight&&d.value){if(h.value){var S=h.value;w.fillStyle=e.background,g(w,S.x,S.y,S.width,S.height,S.borderRadius),w.fill()}var A=d.value.borderRadius;A>0?(w.save(),g(w,d.value.x,d.value.y,d.value.width,d.value.height,A),w.clip(),w.drawImage(E,d.value.x,d.value.y,d.value.width,d.value.height),w.restore()):w.drawImage(E,d.value.x,d.value.y,d.value.width,d.value.height)}}}};return t.onMounted(p),t.watchEffect(p),function(){return t.h(t.Fragment,[t.h("canvas",n(n({},r.attrs),{ref:f,role:"img","aria-label":e.value,style:n(n({},r.attrs.style),{width:"".concat(e.size,"px"),height:"".concat(e.size,"px")})})),e.imageSettings.src&&t.h("img",{ref:v,src:e.imageSettings.src,style:{display:"none"},onLoad:p})])}}}),g=t.defineComponent({name:"Qrcode",props:h,setup:function(e){return function(){return t.h("svg"===e.renderAs?f:v,{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,radius:e.radius})}}});e.QrcodeCanvas=v,e.QrcodeSvg=f,e.default=g,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 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=[],u=0;this.size>u;u++)a.push(!1);for(u=0;this.size>u;u++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();var s=this.addEccAndInterleave(n);if(this.drawCodewords(s),-1==i){var l=1e9;for(u=0;8>u;u++){this.applyMask(u),this.drawFormatBits(u);var d=this.getPenaltyScore();l>d&&(i=u,l=d),this.applyMask(u)}}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,u,s,l){if(void 0===a&&(a=1),void 0===u&&(u=40),void 0===s&&(s=-1),void 0===l&&(l=!0),t.MIN_VERSION>a||a>u||u>t.MAX_VERSION||-1>s||s>7)throw new RangeError("Invalid value");var d,c;for(d=a;;d++){var h=8*t.getNumDataCodewords(d,n),f=i.getTotalBits(e,d);if(h>=f){c=f;break}if(d>=u)throw new RangeError("Data too long")}for(var v=0,g=[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH];g.length>v;v++){var p=g[v];l&&c<=8*t.getNumDataCodewords(d,p)&&(n=p)}for(var m=[],y=0,w=e;w.length>y;y++){var E=w[y];r(E.mode.modeBits,4,m),r(E.numChars,E.mode.numCharCountBits(d),m);for(var C=0,M=E.getData();M.length>C;C++){m.push(M[C])}}o(m.length==c);var R=8*t.getNumDataCodewords(d,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 A=[];m.length>8*A.length;)A.push(0);return m.forEach(function(e,t){return A[t>>>3]|=e<<7-(7&t)}),new t(d,n,A,s)},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,u=Math.floor(t/3);this.setFunctionModule(a,u,i),this.setFunctionModule(u,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],u=Math.floor(t.getNumRawDataModules(r)/8),s=i-u%i,l=Math.floor(u/i),d=[],c=t.reedSolomonComputeDivisor(a),h=0,f=0;i>h;h++){var v=e.slice(f,f+l-a+(s>h?0:1));f+=v.length;var g=t.reedSolomonComputeRemainder(v,c);s>h&&v.push(0),d.push(v.concat(g))}var p=[],m=function(e){d.forEach(function(t,r){e==l-a&&s>r||p.push(t[e])})};for(h=0;d[0].length>h;h++)m(h);return o(p.length==u),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 u=0;2>u;u++){var s=i-u,l=!(i+1&2)?this.size-1-a:a;!this.isFunction[l][s]&&8*e.length>r&&(this.modules[l][s]=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],u=0;this.size>u;u++)this.modules[r][u]==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][u],i=1);e+=this.finderPenaltyTerminateAndCount(n,i,a)*t.PENALTY_N3}for(u=0;this.size>u;u++){n=!1;var s=0;for(a=[0,0,0,0,0,0,0],r=0;this.size>r;r++)this.modules[r][u]==n?5==++s?e+=t.PENALTY_N1:s>5&&e++:(this.finderPenaltyAddHistory(s,a),n||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),n=this.modules[r][u],s=1);e+=this.finderPenaltyTerminateAndCount(n,s,a)*t.PENALTY_N3}for(r=0;this.size-1>r;r++)for(u=0;this.size-1>u;u++){var l=this.modules[r][u];l==this.modules[r][u+1]&&l==this.modules[r+1][u]&&l==this.modules[r+1][u+1]&&(e+=t.PENALTY_N2)}for(var d=0,c=0,h=this.modules;h.length>c;c++){d=h[c].reduce(function(e,t){return e+(t?1:0)},d)}var f=this.size*this.size,v=Math.ceil(Math.abs(20*d-10*f)/f)-1;return o(v>=0&&9>=v),o((e+=v*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=0;var a={L:o.QrCode.Ecc.LOW,M:o.QrCode.Ecc.MEDIUM,Q:o.QrCode.Ecc.QUARTILE,H:o.QrCode.Ecc.HIGH},u=function(){try{(new Path2D).addPath(new Path2D)}catch(e){return!1}return!0}();function s(e){return e in a}function l(e,t,r){var n=t>0&&e[t-1][r],o=e.length-1>t&&e[t+1][r],i=r>0&&e[t][r-1],a=e[t].length-1>r&&e[t][r+1];return{nw:!n&&!i,ne:!n&&!a,se:!o&&!a,sw:!o&&!i}}function d(e){var r=t.computed(function(){var t;return(null!==(t=e.margin)&&void 0!==t?t:0)>>>0}),n=t.computed(function(){var t=s(e.level)?e.level:"L";return o.QrCode.encodeText(e.value,a[t]).getModules()}),i=t.computed(function(){return n.value.length+2*r.value}),u=t.computed(function(){return e.radius>0?function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);for(var n=[],o=Math.min(r,.5),i=0;e.length>i;i++)for(var a=0;e[i].length>a;a++)if(e[i][a]){var u=l(e,i,a),s=u.nw,d=u.ne,c=u.se,h=u.sw,f=a+t,v=i+t;n.push("M".concat(f+(s?o:0)," ").concat(v),"L".concat(f+1-(d?o:0)," ").concat(v)),d&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f+1," ").concat(v+o)),n.push("L".concat(f+1," ").concat(v+1-(c?o:0))),c&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f+1-o," ").concat(v+1)),n.push("L".concat(f+(h?o:0)," ").concat(v+1)),h&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f," ").concat(v+1-o)),n.push("L".concat(f," ").concat(v+(s?o:0))),s&&n.push("A".concat(o," ").concat(o," 0 0 1 ").concat(f+o," ").concat(v)),n.push("z")}return n.join("")}(n.value,r.value,e.radius):function(e,t){void 0===t&&(t=0);for(var r=[],n=0;e.length>n;n++)for(var o=e[n],i=null,a=0;o.length>a;a++){var u=o[a];if(u||null===i)if(a!==o.length-1)u&&null===i&&(i=a);else{if(!u)continue;r.push(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"))}else r.push("M".concat(i+t," ").concat(n+t,"h").concat(a-i,"v1H").concat(i+t,"z")),i=null}return r.join("")}(n.value,r.value)}),d=t.computed(function(){if(!e.imageSettings.src)return null;var t=function(e,t,r,n){var o=n.width,i=n.height,a=n.x,u=n.y,s=e.length+2*r,l=Math.floor(.1*t),d=s/t,c=(o||l)*d,h=(i||l)*d;return{x:null==a?e.length/2-c/2:a*d,y:null==u?e.length/2-h/2:u*d,h:h,w:c,borderRadius:(n.borderRadius||0)*d}}(n.value,e.size,r.value,e.imageSettings);return{x:t.x+r.value,y:t.y+r.value,width:t.w,height:t.h,borderRadius:t.borderRadius}}),c=t.computed(function(){if(!e.imageSettings.excavate||!d.value)return null;var t=2/(e.size/i.value);return{x:d.value.x-t,y:d.value.y-t,width:d.value.width+2*t,height:d.value.height+2*t,borderRadius:d.value.borderRadius}});return{margin:r,numCells:i,cells:n,fgPath:u,imageProps:d,imageBorderProps:c}}var c={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"},radius:{type:Number,required:!1,default:0,validator:function(e){return!isNaN(e)&&e>=0&&.5>=e}},id:{type:String,required:!1}},h=n(n({},c),{renderAs:{type:String,required:!1,default:"canvas",validator:function(e){return["canvas","svg"].indexOf(e)>-1}}}),f=t.defineComponent({name:"QRCodeSvg",props:c,setup:function(e){var r=d(e),o=r.numCells,a=r.fgPath,u=r.imageProps,s=r.imageBorderProps,l=e.id||"v-".concat(i++),c="qrcode.vue-gradient-".concat(l),h="qrcode.vue-logo-clip-path-".concat(l),f=t.computed(function(){return e.gradient?t.h("linear"===e.gradientType?"linearGradient":"radialGradient",n({id:c},"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}),v=t.computed(function(){if(!u.value)return null;var e=u.value.borderRadius;return e>0?t.h("clipPath",{id:h},[t.h("rect",{x:u.value.x,y:u.value.y,width:u.value.width,height:u.value.height,rx:e,ry:e})]):null});return function(){return t.h("svg",{width:e.size,height:e.size,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(o.value," ").concat(o.value),role:"img","aria-label":e.value},[t.h("defs",{},[f.value,v.value]),t.h("rect",{width:"100%",height:"100%",fill:e.background}),t.h("path",{fill:e.gradient?"url(#".concat(c,")"):e.foreground,d:a.value}),s.value&&t.h("rect",{x:s.value.x,y:s.value.y,width:s.value.width,height:s.value.height,fill:e.background,rx:s.value.borderRadius,ry:s.value.borderRadius}),e.imageSettings.src&&u.value&&t.h("image",n(n({href:e.imageSettings.src},u.value),u.value.borderRadius>0?{"clip-path":"url(#".concat(h,")")}:{}))])}}}),v=t.defineComponent({name:"QRCodeCanvas",props:c,setup:function(e,r){var o=d(e),i=o.margin,a=o.cells,s=o.numCells,l=o.fgPath,c=o.imageProps,h=o.imageBorderProps,f=t.ref(null),v=t.ref(null),g=function(e,t,r,n,o,i){e.beginPath(),e.roundRect?e.roundRect(t,r,n,o,i):e.rect(t,r,n,o)},p=function(){var t=e.size,r=e.background,n=e.foreground,o=e.gradient,d=e.gradientType,p=e.gradientStartColor,m=e.gradientEndColor,y=f.value;if(y){var w=y.getContext("2d");if(w){var E=v.value,C="undefined"!=typeof window&&window.devicePixelRatio||1,M=t/s.value*C;if(y.height=y.width=t*C,w.setTransform(M,0,0,M,0,0),w.fillStyle=r,w.fillRect(0,0,s.value,s.value),o){var R=void 0;(R="linear"===d?w.createLinearGradient(0,0,s.value,s.value):w.createRadialGradient(s.value/2,s.value/2,0,s.value/2,s.value/2,s.value/2)).addColorStop(0,p),R.addColorStop(1,m),w.fillStyle=R}else w.fillStyle=n;if(u?w.fill(new Path2D(l.value)):a.value.forEach(function(e,t){e.forEach(function(e,r){e&&w.fillRect(r+i.value,t+i.value,1,1)})}),e.imageSettings.src&&E&&0!==E.naturalWidth&&0!==E.naturalHeight&&c.value){if(h.value){var S=h.value;w.fillStyle=e.background,g(w,S.x,S.y,S.width,S.height,S.borderRadius),w.fill()}var A=c.value.borderRadius;A>0?(w.save(),g(w,c.value.x,c.value.y,c.value.width,c.value.height,A),w.clip(),w.drawImage(E,c.value.x,c.value.y,c.value.width,c.value.height),w.restore()):w.drawImage(E,c.value.x,c.value.y,c.value.width,c.value.height)}}}};return t.onMounted(p),t.watchEffect(p),function(){return t.h(t.Fragment,[t.h("canvas",n(n({},r.attrs),{ref:f,role:"img","aria-label":e.value,style:n(n({},r.attrs.style),{width:"".concat(e.size,"px"),height:"".concat(e.size,"px")})})),e.imageSettings.src&&t.h("img",{ref:v,src:e.imageSettings.src,style:{display:"none"},onLoad:p})])}}}),g=t.defineComponent({name:"Qrcode",props:h,setup:function(e){return function(){return t.h("svg"===e.renderAs?f:v,{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,radius:e.radius,id:e.id})}}});e.QrcodeCanvas=v,e.QrcodeSvg=f,e.default=g,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/dist/qrcode.vue.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* qrcode.vue v3.9.
|
|
2
|
+
* qrcode.vue v3.9.1
|
|
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,11 +910,10 @@ var qrcodegen;
|
|
|
910
910
|
var QR = qrcodegen;
|
|
911
911
|
|
|
912
912
|
var _uid = 0;
|
|
913
|
-
function getUid() {
|
|
914
|
-
if (
|
|
915
|
-
return
|
|
916
|
-
|
|
917
|
-
return "vue-".concat(Math.random().toString(36).slice(2), "-").concat(_uid++);
|
|
913
|
+
function getUid(id) {
|
|
914
|
+
if (id)
|
|
915
|
+
return id;
|
|
916
|
+
return "v-".concat(_uid++);
|
|
918
917
|
}
|
|
919
918
|
var defaultErrorCorrectLevel = 'L';
|
|
920
919
|
var DEFAULT_QR_SIZE = 100;
|
|
@@ -1134,6 +1133,10 @@ var QRCodeProps = {
|
|
|
1134
1133
|
default: 0,
|
|
1135
1134
|
validator: function (r) { return !isNaN(r) && r >= 0 && r <= 0.5; },
|
|
1136
1135
|
},
|
|
1136
|
+
id: {
|
|
1137
|
+
type: String,
|
|
1138
|
+
required: false,
|
|
1139
|
+
},
|
|
1137
1140
|
};
|
|
1138
1141
|
var QRCodeVueProps = __assign(__assign({}, QRCodeProps), { renderAs: {
|
|
1139
1142
|
type: String,
|
|
@@ -1146,7 +1149,7 @@ var QrcodeSvg = vue.defineComponent({
|
|
|
1146
1149
|
props: QRCodeProps,
|
|
1147
1150
|
setup: function (props) {
|
|
1148
1151
|
var _a = useQRCode(props), numCells = _a.numCells, fgPath = _a.fgPath, imageProps = _a.imageProps, imageBorderProps = _a.imageBorderProps;
|
|
1149
|
-
var uid = getUid();
|
|
1152
|
+
var uid = getUid(props.id);
|
|
1150
1153
|
var qrGradientId = "qrcode.vue-gradient-".concat(uid);
|
|
1151
1154
|
var qrLogoClipPathId = "qrcode.vue-logo-clip-path-".concat(uid);
|
|
1152
1155
|
var gradientVNode = vue.computed(function () {
|
|
@@ -1336,6 +1339,7 @@ var QrcodeVue = vue.defineComponent({
|
|
|
1336
1339
|
gradientStartColor: props.gradientStartColor,
|
|
1337
1340
|
gradientEndColor: props.gradientEndColor,
|
|
1338
1341
|
radius: props.radius,
|
|
1342
|
+
id: props.id,
|
|
1339
1343
|
}); };
|
|
1340
1344
|
},
|
|
1341
1345
|
});
|
package/dist/qrcode.vue.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* qrcode.vue v3.9.
|
|
2
|
+
* qrcode.vue v3.9.1
|
|
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, computed, h, ref, onMounted, watchEffect, Fragment
|
|
7
|
+
import { defineComponent, computed, h, ref, onMounted, watchEffect, Fragment } from 'vue';
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -906,11 +906,10 @@ var qrcodegen;
|
|
|
906
906
|
var QR = qrcodegen;
|
|
907
907
|
|
|
908
908
|
var _uid = 0;
|
|
909
|
-
function getUid() {
|
|
910
|
-
if (
|
|
911
|
-
return
|
|
912
|
-
|
|
913
|
-
return "vue-".concat(Math.random().toString(36).slice(2), "-").concat(_uid++);
|
|
909
|
+
function getUid(id) {
|
|
910
|
+
if (id)
|
|
911
|
+
return id;
|
|
912
|
+
return "v-".concat(_uid++);
|
|
914
913
|
}
|
|
915
914
|
var defaultErrorCorrectLevel = 'L';
|
|
916
915
|
var DEFAULT_QR_SIZE = 100;
|
|
@@ -1130,6 +1129,10 @@ var QRCodeProps = {
|
|
|
1130
1129
|
default: 0,
|
|
1131
1130
|
validator: function (r) { return !isNaN(r) && r >= 0 && r <= 0.5; },
|
|
1132
1131
|
},
|
|
1132
|
+
id: {
|
|
1133
|
+
type: String,
|
|
1134
|
+
required: false,
|
|
1135
|
+
},
|
|
1133
1136
|
};
|
|
1134
1137
|
var QRCodeVueProps = __assign(__assign({}, QRCodeProps), { renderAs: {
|
|
1135
1138
|
type: String,
|
|
@@ -1142,7 +1145,7 @@ var QrcodeSvg = defineComponent({
|
|
|
1142
1145
|
props: QRCodeProps,
|
|
1143
1146
|
setup: function (props) {
|
|
1144
1147
|
var _a = useQRCode(props), numCells = _a.numCells, fgPath = _a.fgPath, imageProps = _a.imageProps, imageBorderProps = _a.imageBorderProps;
|
|
1145
|
-
var uid = getUid();
|
|
1148
|
+
var uid = getUid(props.id);
|
|
1146
1149
|
var qrGradientId = "qrcode.vue-gradient-".concat(uid);
|
|
1147
1150
|
var qrLogoClipPathId = "qrcode.vue-logo-clip-path-".concat(uid);
|
|
1148
1151
|
var gradientVNode = computed(function () {
|
|
@@ -1332,6 +1335,7 @@ var QrcodeVue = defineComponent({
|
|
|
1332
1335
|
gradientStartColor: props.gradientStartColor,
|
|
1333
1336
|
gradientEndColor: props.gradientEndColor,
|
|
1334
1337
|
radius: props.radius,
|
|
1338
|
+
id: props.id,
|
|
1335
1339
|
}); };
|
|
1336
1340
|
},
|
|
1337
1341
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qrcode.vue",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.1",
|
|
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/
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./dist/
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/qrcode.vue.esm.js",
|
|
16
16
|
"require": "./dist/qrcode.vue.cjs.js"
|
|
17
17
|
},
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"dependencies": {},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@rollup/plugin-terser": "^1.0.0",
|
|
53
|
-
"@rsbuild/core": "^2.0.
|
|
54
|
-
"@rstest/core": "^0.9.
|
|
55
|
-
"@vue/test-utils": "^2.4.
|
|
53
|
+
"@rsbuild/core": "^2.0.5",
|
|
54
|
+
"@rstest/core": "^0.9.10",
|
|
55
|
+
"@vue/test-utils": "^2.4.10",
|
|
56
56
|
"happy-dom": "^20.9.0",
|
|
57
|
-
"rollup": "^4.60.
|
|
57
|
+
"rollup": "^4.60.3",
|
|
58
58
|
"rollup-plugin-typescript2": "^0.37.0",
|
|
59
59
|
"typescript": "^5.9.3",
|
|
60
|
-
"vue": "^3.5.
|
|
60
|
+
"vue": "^3.5.34"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/dist/rstest.config.d.ts
DELETED
package/dist/src/qrcodegen.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
declare namespace qrcodegen {
|
|
2
|
-
type bit = number;
|
|
3
|
-
type byte = number;
|
|
4
|
-
type int = number;
|
|
5
|
-
export class QrCode {
|
|
6
|
-
readonly version: int;
|
|
7
|
-
readonly errorCorrectionLevel: QrCode.Ecc;
|
|
8
|
-
static encodeText(text: string, ecl: QrCode.Ecc): QrCode;
|
|
9
|
-
static encodeBinary(data: Readonly<Array<byte>>, ecl: QrCode.Ecc): QrCode;
|
|
10
|
-
static encodeSegments(segs: Readonly<Array<QrSegment>>, ecl: QrCode.Ecc, minVersion?: int, maxVersion?: int, mask?: int, boostEcl?: boolean): QrCode;
|
|
11
|
-
readonly size: int;
|
|
12
|
-
readonly mask: int;
|
|
13
|
-
private readonly modules;
|
|
14
|
-
private readonly isFunction;
|
|
15
|
-
constructor(version: int, errorCorrectionLevel: QrCode.Ecc, dataCodewords: Readonly<Array<byte>>, msk: int);
|
|
16
|
-
getModule(x: int, y: int): boolean;
|
|
17
|
-
getModules(): boolean[][];
|
|
18
|
-
private drawFunctionPatterns;
|
|
19
|
-
private drawFormatBits;
|
|
20
|
-
private drawVersion;
|
|
21
|
-
private drawFinderPattern;
|
|
22
|
-
private drawAlignmentPattern;
|
|
23
|
-
private setFunctionModule;
|
|
24
|
-
private addEccAndInterleave;
|
|
25
|
-
private drawCodewords;
|
|
26
|
-
private applyMask;
|
|
27
|
-
private getPenaltyScore;
|
|
28
|
-
private getAlignmentPatternPositions;
|
|
29
|
-
private static getNumRawDataModules;
|
|
30
|
-
private static getNumDataCodewords;
|
|
31
|
-
private static reedSolomonComputeDivisor;
|
|
32
|
-
private static reedSolomonComputeRemainder;
|
|
33
|
-
private static reedSolomonMultiply;
|
|
34
|
-
private finderPenaltyCountPatterns;
|
|
35
|
-
private finderPenaltyTerminateAndCount;
|
|
36
|
-
private finderPenaltyAddHistory;
|
|
37
|
-
static readonly MIN_VERSION: int;
|
|
38
|
-
static readonly MAX_VERSION: int;
|
|
39
|
-
private static readonly PENALTY_N1;
|
|
40
|
-
private static readonly PENALTY_N2;
|
|
41
|
-
private static readonly PENALTY_N3;
|
|
42
|
-
private static readonly PENALTY_N4;
|
|
43
|
-
private static readonly ECC_CODEWORDS_PER_BLOCK;
|
|
44
|
-
private static readonly NUM_ERROR_CORRECTION_BLOCKS;
|
|
45
|
-
}
|
|
46
|
-
export class QrSegment {
|
|
47
|
-
readonly mode: QrSegment.Mode;
|
|
48
|
-
readonly numChars: int;
|
|
49
|
-
private readonly bitData;
|
|
50
|
-
static makeBytes(data: Readonly<Array<byte>>): QrSegment;
|
|
51
|
-
static makeNumeric(digits: string): QrSegment;
|
|
52
|
-
static makeAlphanumeric(text: string): QrSegment;
|
|
53
|
-
static makeSegments(text: string): Array<QrSegment>;
|
|
54
|
-
static makeEci(assignVal: int): QrSegment;
|
|
55
|
-
static isNumeric(text: string): boolean;
|
|
56
|
-
static isAlphanumeric(text: string): boolean;
|
|
57
|
-
constructor(mode: QrSegment.Mode, numChars: int, bitData: Array<bit>);
|
|
58
|
-
getData(): Array<bit>;
|
|
59
|
-
static getTotalBits(segs: Readonly<Array<QrSegment>>, version: int): number;
|
|
60
|
-
private static toUtf8ByteArray;
|
|
61
|
-
private static readonly NUMERIC_REGEX;
|
|
62
|
-
private static readonly ALPHANUMERIC_REGEX;
|
|
63
|
-
private static readonly ALPHANUMERIC_CHARSET;
|
|
64
|
-
}
|
|
65
|
-
export {};
|
|
66
|
-
}
|
|
67
|
-
declare namespace qrcodegen.QrCode {
|
|
68
|
-
type int = number;
|
|
69
|
-
export class Ecc {
|
|
70
|
-
readonly ordinal: int;
|
|
71
|
-
readonly formatBits: int;
|
|
72
|
-
static readonly LOW: Ecc;
|
|
73
|
-
static readonly MEDIUM: Ecc;
|
|
74
|
-
static readonly QUARTILE: Ecc;
|
|
75
|
-
static readonly HIGH: Ecc;
|
|
76
|
-
private constructor();
|
|
77
|
-
}
|
|
78
|
-
export {};
|
|
79
|
-
}
|
|
80
|
-
declare namespace qrcodegen.QrSegment {
|
|
81
|
-
type int = number;
|
|
82
|
-
export class Mode {
|
|
83
|
-
readonly modeBits: int;
|
|
84
|
-
private readonly numBitsCharCount;
|
|
85
|
-
static readonly NUMERIC: Mode;
|
|
86
|
-
static readonly ALPHANUMERIC: Mode;
|
|
87
|
-
static readonly BYTE: Mode;
|
|
88
|
-
static readonly KANJI: Mode;
|
|
89
|
-
static readonly ECI: Mode;
|
|
90
|
-
private constructor();
|
|
91
|
-
numCharCountBits(ver: int): int;
|
|
92
|
-
}
|
|
93
|
-
export {};
|
|
94
|
-
}
|
|
95
|
-
export default qrcodegen;
|