qrcode-alipay 1.0.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.
@@ -0,0 +1,717 @@
1
+ // src/create.ts
2
+ import QRCode from "qrcode";
3
+
4
+ // src/logo.ts
5
+ function createDefaultAlipayLogo(x, y, size) {
6
+ return {
7
+ tag: "svg",
8
+ attrs: {
9
+ x,
10
+ y,
11
+ width: size,
12
+ height: size,
13
+ viewBox: "0 0 47 47",
14
+ "aria-hidden": "true",
15
+ focusable: "false"
16
+ },
17
+ children: [
18
+ {
19
+ tag: "defs",
20
+ children: [
21
+ {
22
+ tag: "rect",
23
+ attrs: {
24
+ id: "alipay-logo-path",
25
+ x: 0,
26
+ y: 0,
27
+ width: 47,
28
+ height: 47,
29
+ rx: 7.5
30
+ }
31
+ },
32
+ {
33
+ tag: "linearGradient",
34
+ attrs: {
35
+ id: "alipay-logo-bg",
36
+ x1: "0%",
37
+ y1: "50%",
38
+ x2: "100%",
39
+ y2: "50%"
40
+ },
41
+ children: [
42
+ {
43
+ tag: "stop",
44
+ attrs: {
45
+ "stop-color": "#179EFF",
46
+ offset: "0%"
47
+ }
48
+ },
49
+ {
50
+ tag: "stop",
51
+ attrs: {
52
+ "stop-color": "#1677FF",
53
+ offset: "100%"
54
+ }
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ tag: "linearGradient",
60
+ attrs: {
61
+ id: "alipay-logo-highlight-a",
62
+ x1: "43.5923819%",
63
+ y1: "97.1205235%",
64
+ x2: "51.5611353%",
65
+ y2: "36.3892384%"
66
+ },
67
+ children: [
68
+ {
69
+ tag: "stop",
70
+ attrs: {
71
+ "stop-color": "#FFFFFF",
72
+ "stop-opacity": 0.699999988,
73
+ offset: "0%"
74
+ }
75
+ },
76
+ {
77
+ tag: "stop",
78
+ attrs: {
79
+ "stop-color": "#FFFFFF",
80
+ "stop-opacity": 0.779999971,
81
+ offset: "13.3333325%"
82
+ }
83
+ },
84
+ {
85
+ tag: "stop",
86
+ attrs: {
87
+ "stop-color": "#FFFFFF",
88
+ "stop-opacity": 0.879999995,
89
+ offset: "31.666665%"
90
+ }
91
+ },
92
+ {
93
+ tag: "stop",
94
+ attrs: {
95
+ "stop-color": "#FFFFFF",
96
+ "stop-opacity": 0.949999988,
97
+ offset: "53.33333%"
98
+ }
99
+ },
100
+ {
101
+ tag: "stop",
102
+ attrs: {
103
+ "stop-color": "#FFFFFF",
104
+ "stop-opacity": 0.99000001,
105
+ offset: "74.999995%"
106
+ }
107
+ },
108
+ {
109
+ tag: "stop",
110
+ attrs: {
111
+ "stop-color": "#FFFFFF",
112
+ offset: "100%"
113
+ }
114
+ }
115
+ ]
116
+ },
117
+ {
118
+ tag: "linearGradient",
119
+ attrs: {
120
+ id: "alipay-logo-highlight-b",
121
+ x1: "41.6085117%",
122
+ y1: "52.2245791%",
123
+ x2: "60.9955549%",
124
+ y2: "40.6569108%"
125
+ },
126
+ children: [
127
+ {
128
+ tag: "stop",
129
+ attrs: {
130
+ "stop-color": "#FFFFFF",
131
+ offset: "0%"
132
+ }
133
+ },
134
+ {
135
+ tag: "stop",
136
+ attrs: {
137
+ "stop-color": "#FFFFFF",
138
+ "stop-opacity": 0.980000019,
139
+ offset: "20.8333342%"
140
+ }
141
+ },
142
+ {
143
+ tag: "stop",
144
+ attrs: {
145
+ "stop-color": "#FFFFFF",
146
+ "stop-opacity": 0.910000026,
147
+ offset: "45.8333352%"
148
+ }
149
+ },
150
+ {
151
+ tag: "stop",
152
+ attrs: {
153
+ "stop-color": "#FFFFFF",
154
+ "stop-opacity": 0.810000002,
155
+ offset: "74.999999%"
156
+ }
157
+ },
158
+ {
159
+ tag: "stop",
160
+ attrs: {
161
+ "stop-color": "#FFFFFF",
162
+ "stop-opacity": 0.699999988,
163
+ offset: "100%"
164
+ }
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ tag: "linearGradient",
170
+ attrs: {
171
+ id: "alipay-logo-highlight-c",
172
+ x1: "25.999999%",
173
+ y1: "49.9925554%",
174
+ x2: "100%",
175
+ y2: "49.9925554%"
176
+ },
177
+ children: [
178
+ {
179
+ tag: "stop",
180
+ attrs: {
181
+ "stop-color": "#FFFFFF",
182
+ offset: "0%"
183
+ }
184
+ },
185
+ {
186
+ tag: "stop",
187
+ attrs: {
188
+ "stop-color": "#FFFFFF",
189
+ "stop-opacity": 0.400000006,
190
+ offset: "100%"
191
+ }
192
+ }
193
+ ]
194
+ },
195
+ {
196
+ tag: "linearGradient",
197
+ attrs: {
198
+ id: "alipay-logo-highlight-d",
199
+ x1: "16.0001332%",
200
+ y1: "50%",
201
+ x2: "100.000834%",
202
+ y2: "50%"
203
+ },
204
+ children: [
205
+ {
206
+ tag: "stop",
207
+ attrs: {
208
+ "stop-color": "#FFFFFF",
209
+ offset: "0%"
210
+ }
211
+ },
212
+ {
213
+ tag: "stop",
214
+ attrs: {
215
+ "stop-color": "#FFFFFF",
216
+ "stop-opacity": 0.5,
217
+ offset: "100%"
218
+ }
219
+ }
220
+ ]
221
+ }
222
+ ]
223
+ },
224
+ {
225
+ tag: "g",
226
+ attrs: {
227
+ stroke: "none",
228
+ "stroke-width": 1,
229
+ fill: "none",
230
+ "fill-rule": "evenodd"
231
+ },
232
+ children: [
233
+ {
234
+ tag: "mask",
235
+ attrs: {
236
+ id: "alipay-logo-mask",
237
+ fill: "white"
238
+ },
239
+ children: [
240
+ {
241
+ tag: "use",
242
+ attrs: {
243
+ href: "#alipay-logo-path"
244
+ }
245
+ }
246
+ ]
247
+ },
248
+ {
249
+ tag: "use",
250
+ attrs: {
251
+ fill: "#FFFFFF",
252
+ href: "#alipay-logo-path"
253
+ }
254
+ },
255
+ {
256
+ tag: "rect",
257
+ attrs: {
258
+ stroke: "#FFFFFF",
259
+ "stroke-width": 2.05241823,
260
+ fill: "url(#alipay-logo-bg)",
261
+ "fill-rule": "nonzero",
262
+ mask: "url(#alipay-logo-mask)",
263
+ x: 0.973790884,
264
+ y: 0.973790884,
265
+ width: 45.0524182,
266
+ height: 45.0524182,
267
+ rx: 6
268
+ }
269
+ },
270
+ {
271
+ tag: "g",
272
+ attrs: {
273
+ mask: "url(#alipay-logo-mask)"
274
+ },
275
+ children: [
276
+ {
277
+ tag: "g",
278
+ attrs: {
279
+ transform: "translate(8.142857, 10.190476)"
280
+ },
281
+ children: [
282
+ {
283
+ tag: "rect",
284
+ attrs: {
285
+ "fill-rule": "nonzero",
286
+ x: 0,
287
+ y: 0,
288
+ width: 31.3968239,
289
+ height: 27.3015862
290
+ }
291
+ },
292
+ {
293
+ tag: "path",
294
+ attrs: {
295
+ d: "M17.742816,4.04394007 L17.742816,0.237326697 C17.742816,0.105373047 17.6342039,0 17.5017738,0 C13.9490309,0 13.6269121,0.87241292 13.6269121,2.01158094 L13.6269121,4.04394007 L5.01163846,4.04394007 C4.51621702,4.04394007 4.2985174,5.1065464 4.29882812,5.91393232 C4.29882812,6.04778433 4.40284172,6.15837812 4.53717715,6.15837812 L13.627389,6.15837812 L13.627389,9.55555534 C9.91700665,9.55555534 7.94851184,9.55555534 7.72190452,9.55555534 C7.0247643,9.55555534 6.78515196,10.5990095 6.78658104,11.3793402 C6.78658104,11.5098686 6.89328718,11.6157179 7.0247643,11.6157179 L23.6318626,11.6157179 C23.8865166,11.6157179 23.9538689,13.1127501 24.1113319,12.9789038 C24.2292786,12.8786497 24.5001163,11.3888502 24.5001163,10.1015615 C24.5001163,9.51883888 23.7903099,9.55555534 23.428791,9.55555534 L17.9496384,9.55555534 L17.9496384,6.14285707 L26.1661358,6.15837812 C26.6615562,6.15837812 26.8792534,5.14228821 26.8789673,4.28838682 C26.8789673,4.15453434 26.774929,4.04394007 26.6405945,4.04394007 L17.742816,4.04394007 Z",
296
+ fill: "#FFFFFF",
297
+ "fill-rule": "nonzero"
298
+ }
299
+ },
300
+ {
301
+ tag: "g",
302
+ attrs: {
303
+ transform: "translate(0.000000, 10.102539)",
304
+ "fill-rule": "nonzero"
305
+ },
306
+ children: [
307
+ {
308
+ tag: "rect",
309
+ attrs: {
310
+ x: 0,
311
+ y: 0,
312
+ width: 31.3968239,
313
+ height: 17.2000275
314
+ }
315
+ },
316
+ {
317
+ tag: "path",
318
+ attrs: {
319
+ d: "M24.3553729,0.47939992 C24.3567953,0.215492636 24.1433825,0 23.8785224,0 L18.8337988,0 C18.8337988,2.99506307 18.1730781,5.57622766 17.1083984,7.71074438 C18.5436915,8.38522625 19.9799376,9.10812378 21.4914489,9.77501202 C23.2559114,6.94797659 24.3348823,3.70846701 24.3548894,0.47939992 L24.3553729,0.47939992 Z",
320
+ fill: "url(#alipay-logo-highlight-a)"
321
+ }
322
+ },
323
+ {
324
+ tag: "g",
325
+ attrs: {
326
+ transform: "translate(0.000000, 4.421875)"
327
+ },
328
+ children: [
329
+ {
330
+ tag: "rect",
331
+ attrs: {
332
+ x: 0,
333
+ y: 0,
334
+ width: 31.3968239,
335
+ height: 12.777669
336
+ }
337
+ },
338
+ {
339
+ tag: "g",
340
+ attrs: {
341
+ transform: "translate(0.000000, 5.681641)"
342
+ },
343
+ children: [
344
+ {
345
+ tag: "rect",
346
+ attrs: {
347
+ x: 0,
348
+ y: 0,
349
+ width: 18.7755203,
350
+ height: 7.05382442
351
+ }
352
+ },
353
+ {
354
+ tag: "path",
355
+ attrs: {
356
+ d: "M1.94238281,0.725270391 C1.94238281,5.44759703 11.7159986,7.35807705 16.2667303,4.42709255 C17.1694469,3.82618117 18.0078526,3.13983226 18.7757549,2.3851335 C18.5089893,2.2071383 16.2614908,0.706758976 15.0586643,0 C9.61045885,6.26447582 1.94238281,4.60461283 1.94238281,0.725270391 Z",
357
+ fill: "url(#alipay-logo-highlight-b)"
358
+ }
359
+ },
360
+ {
361
+ tag: "path",
362
+ attrs: {
363
+ d: "M16.2612572,4.38385558 C11.7105255,7.31484032 1.94262373,5.40103769 1.94214737,0.678710938 L0,0.678710938 C0,4.21867609 3.12925315,7.05425596 7.41036177,7.05425596 C10.773035,7.05425596 13.7660475,6.04276896 16.2612572,4.38433003 L16.2612572,4.38385558 Z",
364
+ fill: "url(#alipay-logo-highlight-c)"
365
+ }
366
+ }
367
+ ]
368
+ },
369
+ {
370
+ tag: "g",
371
+ children: [
372
+ {
373
+ tag: "rect",
374
+ attrs: {
375
+ x: 0,
376
+ y: 0,
377
+ width: 31.3968239,
378
+ height: 12.777669
379
+ }
380
+ },
381
+ {
382
+ tag: "path",
383
+ attrs: {
384
+ d: "M17.1091881,2.6067965 C17.1091881,2.6067965 17.1091881,2.6067965 17.1087132,2.6067965 C14.1033154,1.1951772 11.1007757,0 7.41036224,0 C3.05827498,0 0,2.82276368 0,6.40687132 C0,6.40687132 1.94214749,6.40687132 1.94214749,6.40687132 C1.94214749,4.38294935 4.1748786,2.92481422 6.88397646,2.92481422 C9.5930748,2.92481422 12.4231701,4.12189007 15.0584316,5.68207598 C16.3136578,6.42490864 17.5512581,7.25033045 18.7759972,8.06768417 C22.2658615,10.3968077 25.6509228,12.6618547 29.0326481,12.777669 C23.6068325,12.5806885 21.6280041,6.47047472 17.1087132,2.60727119 L17.1091881,2.6067965 Z",
385
+ fill: "#FFFFFF"
386
+ }
387
+ },
388
+ {
389
+ tag: "path",
390
+ attrs: {
391
+ d: "M28.5255661,12.7351904 C30.7192345,12.7351904 31.2946863,10.0059333 31.3956776,7.85907602 C31.415206,7.43948221 31.0865145,7.0858655 30.6649303,7.07257509 C24.6598501,6.88556147 20.4930706,4.51466763 16.3310547,2.55957031 C20.9246593,6.48637795 22.8934832,12.7351904 28.5255661,12.7351904 L28.5255661,12.7351904 Z",
392
+ fill: "url(#alipay-logo-highlight-d)"
393
+ }
394
+ }
395
+ ]
396
+ }
397
+ ]
398
+ }
399
+ ]
400
+ }
401
+ ]
402
+ }
403
+ ]
404
+ }
405
+ ]
406
+ }
407
+ ]
408
+ };
409
+ }
410
+
411
+ // src/render.ts
412
+ var XML_ESCAPE = {
413
+ "&": "&",
414
+ "<": "&lt;",
415
+ ">": "&gt;",
416
+ '"': "&quot;",
417
+ "'": "&#39;"
418
+ };
419
+ function escapeXml(value) {
420
+ return value.replace(/[&<>"']/g, (char) => XML_ESCAPE[char] ?? char);
421
+ }
422
+ function renderAttribute(name, value) {
423
+ if (value === null || value === void 0 || value === false) return "";
424
+ return ` ${name}="${escapeXml(String(value))}"`;
425
+ }
426
+ function renderSvgNode(node) {
427
+ if (typeof node === "string") return escapeXml(node);
428
+ const attrs = Object.entries(node.attrs ?? {}).map(([name, value]) => renderAttribute(name, value)).join("");
429
+ const children = node.children ?? [];
430
+ if (children.length === 0) {
431
+ return `<${node.tag}${attrs}/>`;
432
+ }
433
+ return `<${node.tag}${attrs}>${children.map(renderSvgNode).join("")}</${node.tag}>`;
434
+ }
435
+ function renderSvgDescriptor(descriptor) {
436
+ return renderSvgNode(descriptor);
437
+ }
438
+ function cloneElementWithAttrs(element, attrs) {
439
+ return {
440
+ ...element,
441
+ attrs: {
442
+ ...element.attrs,
443
+ ...attrs
444
+ },
445
+ children: element.children ? [...element.children] : void 0
446
+ };
447
+ }
448
+
449
+ // src/create.ts
450
+ var DEFAULT_SIZE = 240;
451
+ var DEFAULT_MARGIN = 0;
452
+ var DEFAULT_DARK_COLOR = "#111319";
453
+ var DEFAULT_LIGHT_COLOR = "#ffffff";
454
+ var DEFAULT_FINDER_COLOR = "#1677ff";
455
+ var DEFAULT_LOGO_FRAME_RATIO = 0.22;
456
+ var DEFAULT_LOGO_ICON_RATIO = 1;
457
+ var DEFAULT_LOGO_RADIUS_RATIO = 0.18;
458
+ var DEFAULT_ARIA_LABEL = "Alipay QR code";
459
+ function assertContent(value) {
460
+ if (typeof value !== "string" || value.length === 0) {
461
+ throw new TypeError("qrcode-alipay: value must be a non-empty string.");
462
+ }
463
+ }
464
+ function normalizeSize(size) {
465
+ if (typeof size === "number") {
466
+ return Number.isFinite(size) && size > 0 ? size : DEFAULT_SIZE;
467
+ }
468
+ if (typeof size === "string" && size.trim()) {
469
+ return size;
470
+ }
471
+ return DEFAULT_SIZE;
472
+ }
473
+ function normalizeMargin(margin) {
474
+ if (!Number.isFinite(margin)) return DEFAULT_MARGIN;
475
+ return Math.max(0, Math.round(margin ?? DEFAULT_MARGIN));
476
+ }
477
+ function normalizeRatio(value, fallback, min, max) {
478
+ if (!Number.isFinite(value)) return fallback;
479
+ return Math.min(max, Math.max(min, value ?? fallback));
480
+ }
481
+ function formatNumber(value) {
482
+ if (Number.isInteger(value)) return String(value);
483
+ return Number(value.toFixed(4)).toString();
484
+ }
485
+ function modulePath(x, y) {
486
+ return `M${formatNumber(x)} ${formatNumber(y)}h1v1h-1z`;
487
+ }
488
+ function isFinderModule(row, column, moduleCount) {
489
+ const inTopLeft = row < 7 && column < 7;
490
+ const inTopRight = row < 7 && column >= moduleCount - 7;
491
+ const inBottomLeft = row >= moduleCount - 7 && column < 7;
492
+ return inTopLeft || inTopRight || inBottomLeft;
493
+ }
494
+ function intersectsRect(x, y, rectX, rectY, rectSize) {
495
+ return x < rectX + rectSize && x + 1 > rectX && y < rectY + rectSize && y + 1 > rectY;
496
+ }
497
+ function normalizeLogoOptions(options) {
498
+ if (options.logo === false || options.logo?.enabled === false) {
499
+ return null;
500
+ }
501
+ return {
502
+ frameRatio: normalizeRatio(
503
+ options.logo?.frameRatio,
504
+ DEFAULT_LOGO_FRAME_RATIO,
505
+ 0.12,
506
+ 0.3
507
+ ),
508
+ iconRatio: normalizeRatio(
509
+ options.logo?.iconRatio,
510
+ DEFAULT_LOGO_ICON_RATIO,
511
+ 0.4,
512
+ 0.9
513
+ ),
514
+ frameRadiusRatio: normalizeRatio(
515
+ options.logo?.frameRadiusRatio,
516
+ DEFAULT_LOGO_RADIUS_RATIO,
517
+ 0,
518
+ 0.5
519
+ ),
520
+ frameColor: options.logo?.frameColor ?? DEFAULT_LIGHT_COLOR,
521
+ element: options.logo?.element
522
+ };
523
+ }
524
+ function normalizeFinderOptions(options) {
525
+ if (options.finderPattern === false || options.finderPattern?.enabled === false) {
526
+ return null;
527
+ }
528
+ return {
529
+ color: options.finderPattern?.color ?? DEFAULT_FINDER_COLOR
530
+ };
531
+ }
532
+ function createLogoNodes(options, params) {
533
+ const logo = normalizeLogoOptions(options);
534
+ if (!logo) return [];
535
+ if (typeof logo.element === "function") {
536
+ const custom = logo.element(params);
537
+ return Array.isArray(custom) ? custom : [custom];
538
+ }
539
+ if (logo.element) {
540
+ return [
541
+ cloneElementWithAttrs(logo.element, {
542
+ x: params.x,
543
+ y: params.y,
544
+ width: params.size,
545
+ height: params.size
546
+ })
547
+ ];
548
+ }
549
+ return [createDefaultAlipayLogo(params.x, params.y, params.size)];
550
+ }
551
+ function buildModulePaths(value, margin, moduleCount, logoFrame, finderColorEnabled) {
552
+ const qrData = QRCode.create(value, {
553
+ errorCorrectionLevel: "H"
554
+ });
555
+ const paths = {
556
+ dark: [],
557
+ finder: []
558
+ };
559
+ for (let row = 0; row < moduleCount; row += 1) {
560
+ for (let column = 0; column < moduleCount; column += 1) {
561
+ if (!qrData.modules.get(row, column)) continue;
562
+ const x = column + margin;
563
+ const y = row + margin;
564
+ if (logoFrame && intersectsRect(x, y, logoFrame.x, logoFrame.y, logoFrame.size)) {
565
+ continue;
566
+ }
567
+ const path = modulePath(x, y);
568
+ if (finderColorEnabled && isFinderModule(row, column, moduleCount)) {
569
+ paths.finder.push(path);
570
+ } else {
571
+ paths.dark.push(path);
572
+ }
573
+ }
574
+ }
575
+ return paths;
576
+ }
577
+ function createAlipayQRCode(value, options = {}) {
578
+ return createAlipayQRCodeWithHiddenOptions(
579
+ value,
580
+ options
581
+ );
582
+ }
583
+ function createAlipayQRCodeWithHiddenOptions(value, options = {}) {
584
+ assertContent(value);
585
+ const qrData = QRCode.create(value, {
586
+ errorCorrectionLevel: "H"
587
+ });
588
+ const moduleCount = qrData.modules.size;
589
+ const margin = normalizeMargin(options.margin);
590
+ const viewBoxSize = moduleCount + margin * 2;
591
+ const size = normalizeSize(options.size);
592
+ const lightColor = options.colors?.light ?? DEFAULT_LIGHT_COLOR;
593
+ const darkColor = options.colors?.dark ?? DEFAULT_DARK_COLOR;
594
+ const finderPattern = normalizeFinderOptions(options);
595
+ const logo = normalizeLogoOptions(options);
596
+ const center = margin + moduleCount / 2;
597
+ const logoFrameSize = logo ? moduleCount * logo.frameRatio : 0;
598
+ const logoFrameX = center - logoFrameSize / 2;
599
+ const logoFrameY = center - logoFrameSize / 2;
600
+ const iconSize = logo ? logoFrameSize * logo.iconRatio : 0;
601
+ const iconX = center - iconSize / 2;
602
+ const iconY = center - iconSize / 2;
603
+ const logoFrame = logo ? {
604
+ x: logoFrameX,
605
+ y: logoFrameY,
606
+ size: logoFrameSize
607
+ } : null;
608
+ const modulePaths = buildModulePaths(
609
+ value,
610
+ margin,
611
+ moduleCount,
612
+ logoFrame,
613
+ Boolean(finderPattern)
614
+ );
615
+ const children = [];
616
+ if (options.title) {
617
+ children.push({
618
+ tag: "title",
619
+ children: [options.title]
620
+ });
621
+ }
622
+ children.push({
623
+ tag: "rect",
624
+ attrs: {
625
+ width: viewBoxSize,
626
+ height: viewBoxSize,
627
+ fill: lightColor,
628
+ "data-alipay-qrcode-part": "background"
629
+ }
630
+ });
631
+ children.push({
632
+ tag: "path",
633
+ attrs: {
634
+ d: modulePaths.dark.join(""),
635
+ fill: darkColor,
636
+ "shape-rendering": "crispEdges",
637
+ "data-alipay-qrcode-part": "modules"
638
+ }
639
+ });
640
+ if (finderPattern && modulePaths.finder.length > 0) {
641
+ children.push({
642
+ tag: "path",
643
+ attrs: {
644
+ d: modulePaths.finder.join(""),
645
+ fill: finderPattern.color,
646
+ "shape-rendering": "crispEdges",
647
+ "data-alipay-qrcode-part": "finder-patterns"
648
+ }
649
+ });
650
+ }
651
+ if (logo) {
652
+ const logoParams = {
653
+ x: iconX,
654
+ y: iconY,
655
+ size: iconSize,
656
+ frameX: logoFrameX,
657
+ frameY: logoFrameY,
658
+ frameSize: logoFrameSize,
659
+ viewBoxSize,
660
+ moduleCount,
661
+ margin
662
+ };
663
+ children.push({
664
+ tag: "rect",
665
+ attrs: {
666
+ x: logoFrameX,
667
+ y: logoFrameY,
668
+ width: logoFrameSize,
669
+ height: logoFrameSize,
670
+ rx: logoFrameSize * logo.frameRadiusRatio,
671
+ fill: logo.frameColor,
672
+ "data-alipay-qrcode-part": "logo-frame"
673
+ }
674
+ });
675
+ children.push(...createLogoNodes(options, logoParams));
676
+ }
677
+ return {
678
+ tag: "svg",
679
+ attrs: {
680
+ xmlns: "http://www.w3.org/2000/svg",
681
+ viewBox: `0 0 ${viewBoxSize} ${viewBoxSize}`,
682
+ width: size,
683
+ height: size,
684
+ role: "img",
685
+ "aria-label": options.ariaLabel ?? options.title ?? DEFAULT_ARIA_LABEL,
686
+ class: options.className
687
+ },
688
+ children,
689
+ metadata: {
690
+ moduleCount,
691
+ margin,
692
+ viewBoxSize,
693
+ logo: logo ? {
694
+ frameX: logoFrameX,
695
+ frameY: logoFrameY,
696
+ frameSize: logoFrameSize,
697
+ iconX,
698
+ iconY,
699
+ iconSize
700
+ } : void 0
701
+ }
702
+ };
703
+ }
704
+ function toSvg(value, options = {}) {
705
+ return renderSvgDescriptor(createAlipayQRCode(value, options));
706
+ }
707
+ function toDataURL(value, options = {}) {
708
+ return `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(
709
+ toSvg(value, options)
710
+ )}`;
711
+ }
712
+
713
+ export {
714
+ createAlipayQRCode,
715
+ toSvg,
716
+ toDataURL
717
+ };