@veaba/qrcode-wasm 0.0.4 → 0.0.5

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/pkg/qrcodes.js ADDED
@@ -0,0 +1,1209 @@
1
+ /* @ts-self-types="./qrcodes.d.ts" */
2
+
3
+ /**
4
+ * Canvas 渲染器
5
+ */
6
+ export class CanvasRenderer {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ CanvasRendererFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_canvasrenderer_free(ptr, 0);
16
+ }
17
+ /**
18
+ * 获取推荐的 Canvas 尺寸
19
+ * @param {number} module_count
20
+ * @param {number} cell_size
21
+ * @returns {number}
22
+ */
23
+ static get_recommended_size(module_count, cell_size) {
24
+ const ret = wasm.canvasrenderer_get_recommended_size(module_count, cell_size);
25
+ return ret >>> 0;
26
+ }
27
+ /**
28
+ * @param {number} width
29
+ * @param {number} height
30
+ */
31
+ constructor(width, height) {
32
+ const ret = wasm.canvasrenderer_new(width, height);
33
+ this.__wbg_ptr = ret >>> 0;
34
+ CanvasRendererFinalization.register(this, this.__wbg_ptr, this);
35
+ return this;
36
+ }
37
+ /**
38
+ * 生成 QRCode 并返回像素数据 (RGBA)
39
+ * 返回 Uint8Array,可以直接用于 ImageData
40
+ * @param {string} text
41
+ * @param {number} correct_level
42
+ * @returns {Uint8Array}
43
+ */
44
+ render(text, correct_level) {
45
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
46
+ const len0 = WASM_VECTOR_LEN;
47
+ const ret = wasm.canvasrenderer_render(this.__wbg_ptr, ptr0, len0, correct_level);
48
+ if (ret[3]) {
49
+ throw takeFromExternrefTable0(ret[2]);
50
+ }
51
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
52
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
53
+ return v2;
54
+ }
55
+ /**
56
+ * 生成带边距的 QRCode 像素数据
57
+ * @param {string} text
58
+ * @param {number} correct_level
59
+ * @param {number} quiet_zone
60
+ * @returns {Uint8Array}
61
+ */
62
+ render_with_quiet_zone(text, correct_level, quiet_zone) {
63
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
64
+ const len0 = WASM_VECTOR_LEN;
65
+ const ret = wasm.canvasrenderer_render_with_quiet_zone(this.__wbg_ptr, ptr0, len0, correct_level, quiet_zone);
66
+ if (ret[3]) {
67
+ throw takeFromExternrefTable0(ret[2]);
68
+ }
69
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
70
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
71
+ return v2;
72
+ }
73
+ /**
74
+ * 设置颜色 (RGBA)
75
+ * @param {number} dark_r
76
+ * @param {number} dark_g
77
+ * @param {number} dark_b
78
+ * @param {number} dark_a
79
+ * @param {number} light_r
80
+ * @param {number} light_g
81
+ * @param {number} light_b
82
+ * @param {number} light_a
83
+ */
84
+ set_colors(dark_r, dark_g, dark_b, dark_a, light_r, light_g, light_b, light_a) {
85
+ wasm.canvasrenderer_set_colors(this.__wbg_ptr, dark_r, dark_g, dark_b, dark_a, light_r, light_g, light_b, light_a);
86
+ }
87
+ }
88
+ if (Symbol.dispose) CanvasRenderer.prototype[Symbol.dispose] = CanvasRenderer.prototype.free;
89
+
90
+ /**
91
+ * 错误纠正级别
92
+ * @enum {1 | 0 | 3 | 2}
93
+ */
94
+ export const CorrectLevel = Object.freeze({
95
+ L: 1, "1": "L",
96
+ M: 0, "0": "M",
97
+ Q: 3, "3": "Q",
98
+ H: 2, "2": "H",
99
+ });
100
+
101
+ /**
102
+ * 可复用的 QRCode 生成器
103
+ */
104
+ export class QRCodeGenerator {
105
+ static __wrap(ptr) {
106
+ ptr = ptr >>> 0;
107
+ const obj = Object.create(QRCodeGenerator.prototype);
108
+ obj.__wbg_ptr = ptr;
109
+ QRCodeGeneratorFinalization.register(obj, obj.__wbg_ptr, obj);
110
+ return obj;
111
+ }
112
+ __destroy_into_raw() {
113
+ const ptr = this.__wbg_ptr;
114
+ this.__wbg_ptr = 0;
115
+ QRCodeGeneratorFinalization.unregister(this);
116
+ return ptr;
117
+ }
118
+ free() {
119
+ const ptr = this.__destroy_into_raw();
120
+ wasm.__wbg_qrcodegenerator_free(ptr, 0);
121
+ }
122
+ /**
123
+ * 清除缓存
124
+ */
125
+ clear() {
126
+ wasm.qrcodegenerator_clear(this.__wbg_ptr);
127
+ }
128
+ /**
129
+ * 生成 QRCode(复用实例)
130
+ * @param {string} text
131
+ */
132
+ generate(text) {
133
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
134
+ const len0 = WASM_VECTOR_LEN;
135
+ const ret = wasm.qrcodegenerator_generate(this.__wbg_ptr, ptr0, len0);
136
+ if (ret[1]) {
137
+ throw takeFromExternrefTable0(ret[0]);
138
+ }
139
+ }
140
+ /**
141
+ * 批量生成 QRCode
142
+ * @param {string[]} texts
143
+ * @returns {string[]}
144
+ */
145
+ generate_batch(texts) {
146
+ const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_malloc);
147
+ const len0 = WASM_VECTOR_LEN;
148
+ const ret = wasm.qrcodegenerator_generate_batch(this.__wbg_ptr, ptr0, len0);
149
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
150
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
151
+ return v2;
152
+ }
153
+ /**
154
+ * 获取模块数量
155
+ * @returns {number}
156
+ */
157
+ get_module_count() {
158
+ const ret = wasm.qrcodegenerator_get_module_count(this.__wbg_ptr);
159
+ return ret;
160
+ }
161
+ /**
162
+ * 获取模块数据作为 JSON
163
+ * @returns {string}
164
+ */
165
+ get_modules_json() {
166
+ let deferred1_0;
167
+ let deferred1_1;
168
+ try {
169
+ const ret = wasm.qrcodegenerator_get_modules_json(this.__wbg_ptr);
170
+ deferred1_0 = ret[0];
171
+ deferred1_1 = ret[1];
172
+ return getStringFromWasm0(ret[0], ret[1]);
173
+ } finally {
174
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
175
+ }
176
+ }
177
+ /**
178
+ * 生成并返回 Uint8Array(原始模块数据)
179
+ * @returns {Uint8Array | undefined}
180
+ */
181
+ get_modules_raw() {
182
+ const ret = wasm.qrcodegenerator_get_modules_raw(this.__wbg_ptr);
183
+ let v1;
184
+ if (ret[0] !== 0) {
185
+ v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
186
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
187
+ }
188
+ return v1;
189
+ }
190
+ /**
191
+ * 获取 SVG 字符串(优化版本)
192
+ * @returns {string}
193
+ */
194
+ get_svg() {
195
+ let deferred1_0;
196
+ let deferred1_1;
197
+ try {
198
+ const ret = wasm.qrcodegenerator_get_svg(this.__wbg_ptr);
199
+ deferred1_0 = ret[0];
200
+ deferred1_1 = ret[1];
201
+ return getStringFromWasm0(ret[0], ret[1]);
202
+ } finally {
203
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
204
+ }
205
+ }
206
+ /**
207
+ * 判断指定位置是否为深色
208
+ * @param {number} row
209
+ * @param {number} col
210
+ * @returns {boolean}
211
+ */
212
+ is_dark(row, col) {
213
+ const ret = wasm.qrcodegenerator_is_dark(this.__wbg_ptr, row, col);
214
+ return ret !== 0;
215
+ }
216
+ /**
217
+ * 创建新的生成器
218
+ */
219
+ constructor() {
220
+ const ret = wasm.qrcodegenerator_new();
221
+ this.__wbg_ptr = ret >>> 0;
222
+ QRCodeGeneratorFinalization.register(this, this.__wbg_ptr, this);
223
+ return this;
224
+ }
225
+ /**
226
+ * 设置选项
227
+ * @param {number} width
228
+ * @param {number} height
229
+ * @param {number} correct_level
230
+ */
231
+ set_options(width, height, correct_level) {
232
+ wasm.qrcodegenerator_set_options(this.__wbg_ptr, width, height, correct_level);
233
+ }
234
+ /**
235
+ * 使用选项创建
236
+ * @param {number} width
237
+ * @param {number} height
238
+ * @param {number} correct_level
239
+ * @returns {QRCodeGenerator}
240
+ */
241
+ static with_options(width, height, correct_level) {
242
+ const ret = wasm.qrcodegenerator_with_options(width, height, correct_level);
243
+ return QRCodeGenerator.__wrap(ret);
244
+ }
245
+ }
246
+ if (Symbol.dispose) QRCodeGenerator.prototype[Symbol.dispose] = QRCodeGenerator.prototype.free;
247
+
248
+ /**
249
+ * QRCode 样式选项
250
+ */
251
+ export class QRCodeStyle {
252
+ __destroy_into_raw() {
253
+ const ptr = this.__wbg_ptr;
254
+ this.__wbg_ptr = 0;
255
+ QRCodeStyleFinalization.unregister(this);
256
+ return ptr;
257
+ }
258
+ free() {
259
+ const ptr = this.__destroy_into_raw();
260
+ wasm.__wbg_qrcodestyle_free(ptr, 0);
261
+ }
262
+ constructor() {
263
+ const ret = wasm.qrcodestyle_new();
264
+ this.__wbg_ptr = ret >>> 0;
265
+ QRCodeStyleFinalization.register(this, this.__wbg_ptr, this);
266
+ return this;
267
+ }
268
+ /**
269
+ * @param {number} radius
270
+ */
271
+ set_border_radius(radius) {
272
+ wasm.qrcodestyle_set_border_radius(this.__wbg_ptr, radius);
273
+ }
274
+ /**
275
+ * @param {string} dark
276
+ * @param {string} light
277
+ */
278
+ set_colors(dark, light) {
279
+ const ptr0 = passStringToWasm0(dark, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
280
+ const len0 = WASM_VECTOR_LEN;
281
+ const ptr1 = passStringToWasm0(light, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
282
+ const len1 = WASM_VECTOR_LEN;
283
+ wasm.qrcodestyle_set_colors(this.__wbg_ptr, ptr0, len0, ptr1, len1);
284
+ }
285
+ /**
286
+ * @param {boolean} enabled
287
+ * @param {string} color1
288
+ * @param {string} color2
289
+ */
290
+ set_gradient(enabled, color1, color2) {
291
+ const ptr0 = passStringToWasm0(color1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ptr1 = passStringToWasm0(color2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
294
+ const len1 = WASM_VECTOR_LEN;
295
+ wasm.qrcodestyle_set_gradient(this.__wbg_ptr, enabled, ptr0, len0, ptr1, len1);
296
+ }
297
+ /**
298
+ * @param {boolean} enabled
299
+ * @param {number} ratio
300
+ */
301
+ set_logo(enabled, ratio) {
302
+ wasm.qrcodestyle_set_logo(this.__wbg_ptr, enabled, ratio);
303
+ }
304
+ /**
305
+ * @param {number} zone
306
+ */
307
+ set_quiet_zone(zone) {
308
+ wasm.qrcodestyle_set_quiet_zone(this.__wbg_ptr, zone);
309
+ }
310
+ /**
311
+ * @param {number} size
312
+ */
313
+ set_size(size) {
314
+ wasm.qrcodestyle_set_size(this.__wbg_ptr, size);
315
+ }
316
+ }
317
+ if (Symbol.dispose) QRCodeStyle.prototype[Symbol.dispose] = QRCodeStyle.prototype.free;
318
+
319
+ /**
320
+ * QRCode WASM 包装器(向后兼容)
321
+ */
322
+ export class QRCodeWasm {
323
+ static __wrap(ptr) {
324
+ ptr = ptr >>> 0;
325
+ const obj = Object.create(QRCodeWasm.prototype);
326
+ obj.__wbg_ptr = ptr;
327
+ QRCodeWasmFinalization.register(obj, obj.__wbg_ptr, obj);
328
+ return obj;
329
+ }
330
+ __destroy_into_raw() {
331
+ const ptr = this.__wbg_ptr;
332
+ this.__wbg_ptr = 0;
333
+ QRCodeWasmFinalization.unregister(this);
334
+ return ptr;
335
+ }
336
+ free() {
337
+ const ptr = this.__destroy_into_raw();
338
+ wasm.__wbg_qrcodewasm_free(ptr, 0);
339
+ }
340
+ /**
341
+ * 获取模块数量
342
+ * @returns {number}
343
+ */
344
+ get_module_count() {
345
+ const ret = wasm.qrcodewasm_get_module_count(this.__wbg_ptr);
346
+ return ret;
347
+ }
348
+ /**
349
+ * 获取模块数据作为 JSON 字符串
350
+ * @returns {string}
351
+ */
352
+ get_modules_json() {
353
+ let deferred1_0;
354
+ let deferred1_1;
355
+ try {
356
+ const ret = wasm.qrcodewasm_get_modules_json(this.__wbg_ptr);
357
+ deferred1_0 = ret[0];
358
+ deferred1_1 = ret[1];
359
+ return getStringFromWasm0(ret[0], ret[1]);
360
+ } finally {
361
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
362
+ }
363
+ }
364
+ /**
365
+ * 获取 SVG 字符串
366
+ * @returns {string}
367
+ */
368
+ get_svg() {
369
+ let deferred1_0;
370
+ let deferred1_1;
371
+ try {
372
+ const ret = wasm.qrcodewasm_get_svg(this.__wbg_ptr);
373
+ deferred1_0 = ret[0];
374
+ deferred1_1 = ret[1];
375
+ return getStringFromWasm0(ret[0], ret[1]);
376
+ } finally {
377
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
378
+ }
379
+ }
380
+ /**
381
+ * 判断指定位置是否为深色
382
+ * @param {number} row
383
+ * @param {number} col
384
+ * @returns {boolean}
385
+ */
386
+ is_dark(row, col) {
387
+ const ret = wasm.qrcodewasm_is_dark(this.__wbg_ptr, row, col);
388
+ return ret !== 0;
389
+ }
390
+ /**
391
+ * 生成 QRCode
392
+ * @param {string} text
393
+ */
394
+ make_code(text) {
395
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
396
+ const len0 = WASM_VECTOR_LEN;
397
+ wasm.qrcodewasm_make_code(this.__wbg_ptr, ptr0, len0);
398
+ }
399
+ /**
400
+ * 创建新的 QRCode
401
+ */
402
+ constructor() {
403
+ const ret = wasm.qrcodewasm_new();
404
+ this.__wbg_ptr = ret >>> 0;
405
+ QRCodeWasmFinalization.register(this, this.__wbg_ptr, this);
406
+ return this;
407
+ }
408
+ /**
409
+ * 使用选项创建 QRCode
410
+ * @param {number} width
411
+ * @param {number} height
412
+ * @param {CorrectLevel} correct_level
413
+ * @returns {QRCodeWasm}
414
+ */
415
+ static with_options(width, height, correct_level) {
416
+ const ret = wasm.qrcodewasm_with_options(width, height, correct_level);
417
+ return QRCodeWasm.__wrap(ret);
418
+ }
419
+ }
420
+ if (Symbol.dispose) QRCodeWasm.prototype[Symbol.dispose] = QRCodeWasm.prototype.free;
421
+
422
+ /**
423
+ * 样式化 QRCode 生成器
424
+ */
425
+ export class StyledQRCode {
426
+ static __wrap(ptr) {
427
+ ptr = ptr >>> 0;
428
+ const obj = Object.create(StyledQRCode.prototype);
429
+ obj.__wbg_ptr = ptr;
430
+ StyledQRCodeFinalization.register(obj, obj.__wbg_ptr, obj);
431
+ return obj;
432
+ }
433
+ __destroy_into_raw() {
434
+ const ptr = this.__wbg_ptr;
435
+ this.__wbg_ptr = 0;
436
+ StyledQRCodeFinalization.unregister(this);
437
+ return ptr;
438
+ }
439
+ free() {
440
+ const ptr = this.__destroy_into_raw();
441
+ wasm.__wbg_styledqrcode_free(ptr, 0);
442
+ }
443
+ /**
444
+ * 生成 QRCode
445
+ * @param {string} text
446
+ * @param {number} correct_level
447
+ */
448
+ generate(text, correct_level) {
449
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
450
+ const len0 = WASM_VECTOR_LEN;
451
+ const ret = wasm.styledqrcode_generate(this.__wbg_ptr, ptr0, len0, correct_level);
452
+ if (ret[1]) {
453
+ throw takeFromExternrefTable0(ret[0]);
454
+ }
455
+ }
456
+ /**
457
+ * 获取 Logo 区域信息(用于外部添加 Logo)
458
+ * @returns {Int32Array | undefined}
459
+ */
460
+ get_logo_area() {
461
+ const ret = wasm.styledqrcode_get_logo_area(this.__wbg_ptr);
462
+ let v1;
463
+ if (ret[0] !== 0) {
464
+ v1 = getArrayI32FromWasm0(ret[0], ret[1]).slice();
465
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
466
+ }
467
+ return v1;
468
+ }
469
+ /**
470
+ * 获取模块数量
471
+ * @returns {number}
472
+ */
473
+ get_module_count() {
474
+ const ret = wasm.styledqrcode_get_module_count(this.__wbg_ptr);
475
+ return ret;
476
+ }
477
+ /**
478
+ * 获取 SVG(带样式)
479
+ * @returns {string}
480
+ */
481
+ get_styled_svg() {
482
+ let deferred1_0;
483
+ let deferred1_1;
484
+ try {
485
+ const ret = wasm.styledqrcode_get_styled_svg(this.__wbg_ptr);
486
+ deferred1_0 = ret[0];
487
+ deferred1_1 = ret[1];
488
+ return getStringFromWasm0(ret[0], ret[1]);
489
+ } finally {
490
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
491
+ }
492
+ }
493
+ constructor() {
494
+ const ret = wasm.styledqrcode_new();
495
+ this.__wbg_ptr = ret >>> 0;
496
+ StyledQRCodeFinalization.register(this, this.__wbg_ptr, this);
497
+ return this;
498
+ }
499
+ /**
500
+ * @param {QRCodeStyle} style
501
+ * @returns {StyledQRCode}
502
+ */
503
+ static with_style(style) {
504
+ _assertClass(style, QRCodeStyle);
505
+ var ptr0 = style.__destroy_into_raw();
506
+ const ret = wasm.styledqrcode_with_style(ptr0);
507
+ return StyledQRCode.__wrap(ret);
508
+ }
509
+ }
510
+ if (Symbol.dispose) StyledQRCode.prototype[Symbol.dispose] = StyledQRCode.prototype.free;
511
+
512
+ /**
513
+ * 支付宝样式 QRCode - 蓝色主题
514
+ * @param {string} text
515
+ * @param {number} size
516
+ * @returns {string}
517
+ */
518
+ export function generate_alipay_style_qrcode(text, size) {
519
+ let deferred2_0;
520
+ let deferred2_1;
521
+ try {
522
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
523
+ const len0 = WASM_VECTOR_LEN;
524
+ const ret = wasm.generate_alipay_style_qrcode(ptr0, len0, size);
525
+ deferred2_0 = ret[0];
526
+ deferred2_1 = ret[1];
527
+ return getStringFromWasm0(ret[0], ret[1]);
528
+ } finally {
529
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
530
+ }
531
+ }
532
+
533
+ /**
534
+ * 赛博朋克样式 QRCode - 霓虹效果
535
+ * @param {string} text
536
+ * @param {number} size
537
+ * @returns {string}
538
+ */
539
+ export function generate_cyberpunk_style_qrcode(text, size) {
540
+ let deferred2_0;
541
+ let deferred2_1;
542
+ try {
543
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
544
+ const len0 = WASM_VECTOR_LEN;
545
+ const ret = wasm.generate_cyberpunk_style_qrcode(ptr0, len0, size);
546
+ deferred2_0 = ret[0];
547
+ deferred2_1 = ret[1];
548
+ return getStringFromWasm0(ret[0], ret[1]);
549
+ } finally {
550
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
551
+ }
552
+ }
553
+
554
+ /**
555
+ * 抖音样式 QRCode - 黑色背景,青色/洋红渐变
556
+ * @param {string} text
557
+ * @param {number} size
558
+ * @returns {string}
559
+ */
560
+ export function generate_douyin_style_qrcode(text, size) {
561
+ let deferred2_0;
562
+ let deferred2_1;
563
+ try {
564
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
565
+ const len0 = WASM_VECTOR_LEN;
566
+ const ret = wasm.generate_douyin_style_qrcode(ptr0, len0, size);
567
+ deferred2_0 = ret[0];
568
+ deferred2_1 = ret[1];
569
+ return getStringFromWasm0(ret[0], ret[1]);
570
+ } finally {
571
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
572
+ }
573
+ }
574
+
575
+ /**
576
+ * 快速生成渐变 QRCode
577
+ * @param {string} text
578
+ * @param {number} size
579
+ * @param {string} color1
580
+ * @param {string} color2
581
+ * @returns {string}
582
+ */
583
+ export function generate_gradient_qrcode(text, size, color1, color2) {
584
+ let deferred4_0;
585
+ let deferred4_1;
586
+ try {
587
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
588
+ const len0 = WASM_VECTOR_LEN;
589
+ const ptr1 = passStringToWasm0(color1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
590
+ const len1 = WASM_VECTOR_LEN;
591
+ const ptr2 = passStringToWasm0(color2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
592
+ const len2 = WASM_VECTOR_LEN;
593
+ const ret = wasm.generate_gradient_qrcode(ptr0, len0, size, ptr1, len1, ptr2, len2);
594
+ deferred4_0 = ret[0];
595
+ deferred4_1 = ret[1];
596
+ return getStringFromWasm0(ret[0], ret[1]);
597
+ } finally {
598
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
599
+ }
600
+ }
601
+
602
+ /**
603
+ * 极简样式 QRCode - 细边框,大圆角
604
+ * @param {string} text
605
+ * @param {number} size
606
+ * @returns {string}
607
+ */
608
+ export function generate_minimal_style_qrcode(text, size) {
609
+ let deferred2_0;
610
+ let deferred2_1;
611
+ try {
612
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
613
+ const len0 = WASM_VECTOR_LEN;
614
+ const ret = wasm.generate_minimal_style_qrcode(ptr0, len0, size);
615
+ deferred2_0 = ret[0];
616
+ deferred2_1 = ret[1];
617
+ return getStringFromWasm0(ret[0], ret[1]);
618
+ } finally {
619
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
620
+ }
621
+ }
622
+
623
+ /**
624
+ * 生成 QRCode 并返回模块数据(向后兼容)
625
+ * @param {string} text
626
+ * @param {CorrectLevel} correct_level
627
+ * @returns {QRCodeWasm}
628
+ */
629
+ export function generate_qrcode(text, correct_level) {
630
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
631
+ const len0 = WASM_VECTOR_LEN;
632
+ const ret = wasm.generate_qrcode(ptr0, len0, correct_level);
633
+ return QRCodeWasm.__wrap(ret);
634
+ }
635
+
636
+ /**
637
+ * 批量生成工具函数
638
+ * @param {string[]} texts
639
+ * @param {number} correct_level
640
+ * @returns {string[]}
641
+ */
642
+ export function generate_qrcode_batch(texts, correct_level) {
643
+ const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_malloc);
644
+ const len0 = WASM_VECTOR_LEN;
645
+ const ret = wasm.generate_qrcode_batch(ptr0, len0, correct_level);
646
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
647
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
648
+ return v2;
649
+ }
650
+
651
+ /**
652
+ * 快速生成单个 QRCode
653
+ * @param {string} text
654
+ * @param {number} size
655
+ * @returns {string}
656
+ */
657
+ export function generate_qrcode_fast(text, size) {
658
+ let deferred2_0;
659
+ let deferred2_1;
660
+ try {
661
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
662
+ const len0 = WASM_VECTOR_LEN;
663
+ const ret = wasm.generate_qrcode_fast(ptr0, len0, size);
664
+ deferred2_0 = ret[0];
665
+ deferred2_1 = ret[1];
666
+ return getStringFromWasm0(ret[0], ret[1]);
667
+ } finally {
668
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
669
+ }
670
+ }
671
+
672
+ /**
673
+ * 快速生成带 Logo 区域的 QRCode
674
+ * @param {string} text
675
+ * @param {number} size
676
+ * @param {number} logo_ratio
677
+ * @returns {string}
678
+ */
679
+ export function generate_qrcode_with_logo_area(text, size, logo_ratio) {
680
+ let deferred2_0;
681
+ let deferred2_1;
682
+ try {
683
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
684
+ const len0 = WASM_VECTOR_LEN;
685
+ const ret = wasm.generate_qrcode_with_logo_area(ptr0, len0, size, logo_ratio);
686
+ deferred2_0 = ret[0];
687
+ deferred2_1 = ret[1];
688
+ return getStringFromWasm0(ret[0], ret[1]);
689
+ } finally {
690
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
691
+ }
692
+ }
693
+
694
+ /**
695
+ * 复古样式 QRCode - sepia 色调
696
+ * @param {string} text
697
+ * @param {number} size
698
+ * @returns {string}
699
+ */
700
+ export function generate_retro_style_qrcode(text, size) {
701
+ let deferred2_0;
702
+ let deferred2_1;
703
+ try {
704
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
705
+ const len0 = WASM_VECTOR_LEN;
706
+ const ret = wasm.generate_retro_style_qrcode(ptr0, len0, size);
707
+ deferred2_0 = ret[0];
708
+ deferred2_1 = ret[1];
709
+ return getStringFromWasm0(ret[0], ret[1]);
710
+ } finally {
711
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
712
+ }
713
+ }
714
+
715
+ /**
716
+ * 快速生成圆角 QRCode
717
+ * @param {string} text
718
+ * @param {number} size
719
+ * @param {number} radius
720
+ * @returns {string}
721
+ */
722
+ export function generate_rounded_qrcode(text, size, radius) {
723
+ let deferred2_0;
724
+ let deferred2_1;
725
+ try {
726
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
727
+ const len0 = WASM_VECTOR_LEN;
728
+ const ret = wasm.generate_rounded_qrcode(ptr0, len0, size, radius);
729
+ deferred2_0 = ret[0];
730
+ deferred2_1 = ret[1];
731
+ return getStringFromWasm0(ret[0], ret[1]);
732
+ } finally {
733
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
734
+ }
735
+ }
736
+
737
+ /**
738
+ * 微信样式 QRCode - 绿色主题
739
+ * @param {string} text
740
+ * @param {number} size
741
+ * @returns {string}
742
+ */
743
+ export function generate_wechat_style_qrcode(text, size) {
744
+ let deferred2_0;
745
+ let deferred2_1;
746
+ try {
747
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
748
+ const len0 = WASM_VECTOR_LEN;
749
+ const ret = wasm.generate_wechat_style_qrcode(ptr0, len0, size);
750
+ deferred2_0 = ret[0];
751
+ deferred2_1 = ret[1];
752
+ return getStringFromWasm0(ret[0], ret[1]);
753
+ } finally {
754
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
755
+ }
756
+ }
757
+
758
+ /**
759
+ * 小红书样式 QRCode - 红色主题
760
+ * @param {string} text
761
+ * @param {number} size
762
+ * @returns {string}
763
+ */
764
+ export function generate_xiaohongshu_style_qrcode(text, size) {
765
+ let deferred2_0;
766
+ let deferred2_1;
767
+ try {
768
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
769
+ const len0 = WASM_VECTOR_LEN;
770
+ const ret = wasm.generate_xiaohongshu_style_qrcode(ptr0, len0, size);
771
+ deferred2_0 = ret[0];
772
+ deferred2_1 = ret[1];
773
+ return getStringFromWasm0(ret[0], ret[1]);
774
+ } finally {
775
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
776
+ }
777
+ }
778
+
779
+ /**
780
+ * 获取版本信息
781
+ * @returns {string}
782
+ */
783
+ export function get_version_info() {
784
+ let deferred1_0;
785
+ let deferred1_1;
786
+ try {
787
+ const ret = wasm.get_version_info();
788
+ deferred1_0 = ret[0];
789
+ deferred1_1 = ret[1];
790
+ return getStringFromWasm0(ret[0], ret[1]);
791
+ } finally {
792
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
793
+ }
794
+ }
795
+
796
+ /**
797
+ * 简单的问候函数
798
+ */
799
+ export function greet() {
800
+ wasm.greet();
801
+ }
802
+
803
+ /**
804
+ * 初始化线程池(用于并行计算)
805
+ * @param {number} num_threads
806
+ */
807
+ export function init_thread_pool(num_threads) {
808
+ const ret = wasm.init_thread_pool(num_threads);
809
+ if (ret[1]) {
810
+ throw takeFromExternrefTable0(ret[0]);
811
+ }
812
+ }
813
+
814
+ /**
815
+ * 检查是否支持并行
816
+ * @returns {boolean}
817
+ */
818
+ export function is_parallel_supported() {
819
+ const ret = wasm.is_parallel_supported();
820
+ return ret !== 0;
821
+ }
822
+
823
+ /**
824
+ * 批量渲染到像素数组 (返回 js_sys::Array)
825
+ * @param {string[]} texts
826
+ * @param {number} width
827
+ * @param {number} height
828
+ * @returns {Array<any>}
829
+ */
830
+ export function render_qrcode_batch_pixels(texts, width, height) {
831
+ const ptr0 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_malloc);
832
+ const len0 = WASM_VECTOR_LEN;
833
+ const ret = wasm.render_qrcode_batch_pixels(ptr0, len0, width, height);
834
+ return ret;
835
+ }
836
+
837
+ /**
838
+ * 快速渲染函数
839
+ * @param {string} text
840
+ * @param {number} width
841
+ * @param {number} height
842
+ * @returns {Uint8Array}
843
+ */
844
+ export function render_qrcode_to_pixels(text, width, height) {
845
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
846
+ const len0 = WASM_VECTOR_LEN;
847
+ const ret = wasm.render_qrcode_to_pixels(ptr0, len0, width, height);
848
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
849
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
850
+ return v2;
851
+ }
852
+
853
+ /**
854
+ * 初始化 panic hook
855
+ */
856
+ export function start() {
857
+ wasm.start();
858
+ }
859
+
860
+ /**
861
+ * 获取版本号
862
+ * @returns {string}
863
+ */
864
+ export function version() {
865
+ let deferred1_0;
866
+ let deferred1_1;
867
+ try {
868
+ const ret = wasm.version();
869
+ deferred1_0 = ret[0];
870
+ deferred1_1 = ret[1];
871
+ return getStringFromWasm0(ret[0], ret[1]);
872
+ } finally {
873
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
874
+ }
875
+ }
876
+
877
+ function __wbg_get_imports() {
878
+ const import0 = {
879
+ __proto__: null,
880
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
881
+ const obj = arg1;
882
+ const ret = typeof(obj) === 'string' ? obj : undefined;
883
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
884
+ var len1 = WASM_VECTOR_LEN;
885
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
886
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
887
+ },
888
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
889
+ throw new Error(getStringFromWasm0(arg0, arg1));
890
+ },
891
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
892
+ let deferred0_0;
893
+ let deferred0_1;
894
+ try {
895
+ deferred0_0 = arg0;
896
+ deferred0_1 = arg1;
897
+ console.error(getStringFromWasm0(arg0, arg1));
898
+ } finally {
899
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
900
+ }
901
+ },
902
+ __wbg_log_6b5ca2e6124b2808: function(arg0) {
903
+ console.log(arg0);
904
+ },
905
+ __wbg_new_3eb36ae241fe6f44: function() {
906
+ const ret = new Array();
907
+ return ret;
908
+ },
909
+ __wbg_new_8a6f238a6ece86ea: function() {
910
+ const ret = new Error();
911
+ return ret;
912
+ },
913
+ __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
914
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
915
+ return ret;
916
+ },
917
+ __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
918
+ const ret = arg0.push(arg1);
919
+ return ret;
920
+ },
921
+ __wbg_random_912284dbf636f269: function() {
922
+ const ret = Math.random();
923
+ return ret;
924
+ },
925
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
926
+ const ret = arg1.stack;
927
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
928
+ const len1 = WASM_VECTOR_LEN;
929
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
930
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
931
+ },
932
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
933
+ // Cast intrinsic for `Ref(String) -> Externref`.
934
+ const ret = getStringFromWasm0(arg0, arg1);
935
+ return ret;
936
+ },
937
+ __wbindgen_init_externref_table: function() {
938
+ const table = wasm.__wbindgen_externrefs;
939
+ const offset = table.grow(4);
940
+ table.set(0, undefined);
941
+ table.set(offset + 0, undefined);
942
+ table.set(offset + 1, null);
943
+ table.set(offset + 2, true);
944
+ table.set(offset + 3, false);
945
+ },
946
+ };
947
+ return {
948
+ __proto__: null,
949
+ "./qrcodes_bg.js": import0,
950
+ };
951
+ }
952
+
953
+ const CanvasRendererFinalization = (typeof FinalizationRegistry === 'undefined')
954
+ ? { register: () => {}, unregister: () => {} }
955
+ : new FinalizationRegistry(ptr => wasm.__wbg_canvasrenderer_free(ptr >>> 0, 1));
956
+ const QRCodeGeneratorFinalization = (typeof FinalizationRegistry === 'undefined')
957
+ ? { register: () => {}, unregister: () => {} }
958
+ : new FinalizationRegistry(ptr => wasm.__wbg_qrcodegenerator_free(ptr >>> 0, 1));
959
+ const QRCodeStyleFinalization = (typeof FinalizationRegistry === 'undefined')
960
+ ? { register: () => {}, unregister: () => {} }
961
+ : new FinalizationRegistry(ptr => wasm.__wbg_qrcodestyle_free(ptr >>> 0, 1));
962
+ const QRCodeWasmFinalization = (typeof FinalizationRegistry === 'undefined')
963
+ ? { register: () => {}, unregister: () => {} }
964
+ : new FinalizationRegistry(ptr => wasm.__wbg_qrcodewasm_free(ptr >>> 0, 1));
965
+ const StyledQRCodeFinalization = (typeof FinalizationRegistry === 'undefined')
966
+ ? { register: () => {}, unregister: () => {} }
967
+ : new FinalizationRegistry(ptr => wasm.__wbg_styledqrcode_free(ptr >>> 0, 1));
968
+
969
+ function addToExternrefTable0(obj) {
970
+ const idx = wasm.__externref_table_alloc();
971
+ wasm.__wbindgen_externrefs.set(idx, obj);
972
+ return idx;
973
+ }
974
+
975
+ function _assertClass(instance, klass) {
976
+ if (!(instance instanceof klass)) {
977
+ throw new Error(`expected instance of ${klass.name}`);
978
+ }
979
+ }
980
+
981
+ function getArrayI32FromWasm0(ptr, len) {
982
+ ptr = ptr >>> 0;
983
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
984
+ }
985
+
986
+ function getArrayJsValueFromWasm0(ptr, len) {
987
+ ptr = ptr >>> 0;
988
+ const mem = getDataViewMemory0();
989
+ const result = [];
990
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
991
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
992
+ }
993
+ wasm.__externref_drop_slice(ptr, len);
994
+ return result;
995
+ }
996
+
997
+ function getArrayU8FromWasm0(ptr, len) {
998
+ ptr = ptr >>> 0;
999
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1000
+ }
1001
+
1002
+ let cachedDataViewMemory0 = null;
1003
+ function getDataViewMemory0() {
1004
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1005
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1006
+ }
1007
+ return cachedDataViewMemory0;
1008
+ }
1009
+
1010
+ let cachedInt32ArrayMemory0 = null;
1011
+ function getInt32ArrayMemory0() {
1012
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
1013
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
1014
+ }
1015
+ return cachedInt32ArrayMemory0;
1016
+ }
1017
+
1018
+ function getStringFromWasm0(ptr, len) {
1019
+ ptr = ptr >>> 0;
1020
+ return decodeText(ptr, len);
1021
+ }
1022
+
1023
+ let cachedUint8ArrayMemory0 = null;
1024
+ function getUint8ArrayMemory0() {
1025
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1026
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1027
+ }
1028
+ return cachedUint8ArrayMemory0;
1029
+ }
1030
+
1031
+ function isLikeNone(x) {
1032
+ return x === undefined || x === null;
1033
+ }
1034
+
1035
+ function passArrayJsValueToWasm0(array, malloc) {
1036
+ const ptr = malloc(array.length * 4, 4) >>> 0;
1037
+ for (let i = 0; i < array.length; i++) {
1038
+ const add = addToExternrefTable0(array[i]);
1039
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
1040
+ }
1041
+ WASM_VECTOR_LEN = array.length;
1042
+ return ptr;
1043
+ }
1044
+
1045
+ function passStringToWasm0(arg, malloc, realloc) {
1046
+ if (realloc === undefined) {
1047
+ const buf = cachedTextEncoder.encode(arg);
1048
+ const ptr = malloc(buf.length, 1) >>> 0;
1049
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1050
+ WASM_VECTOR_LEN = buf.length;
1051
+ return ptr;
1052
+ }
1053
+
1054
+ let len = arg.length;
1055
+ let ptr = malloc(len, 1) >>> 0;
1056
+
1057
+ const mem = getUint8ArrayMemory0();
1058
+
1059
+ let offset = 0;
1060
+
1061
+ for (; offset < len; offset++) {
1062
+ const code = arg.charCodeAt(offset);
1063
+ if (code > 0x7F) break;
1064
+ mem[ptr + offset] = code;
1065
+ }
1066
+ if (offset !== len) {
1067
+ if (offset !== 0) {
1068
+ arg = arg.slice(offset);
1069
+ }
1070
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1071
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1072
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1073
+
1074
+ offset += ret.written;
1075
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1076
+ }
1077
+
1078
+ WASM_VECTOR_LEN = offset;
1079
+ return ptr;
1080
+ }
1081
+
1082
+ function takeFromExternrefTable0(idx) {
1083
+ const value = wasm.__wbindgen_externrefs.get(idx);
1084
+ wasm.__externref_table_dealloc(idx);
1085
+ return value;
1086
+ }
1087
+
1088
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1089
+ cachedTextDecoder.decode();
1090
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1091
+ let numBytesDecoded = 0;
1092
+ function decodeText(ptr, len) {
1093
+ numBytesDecoded += len;
1094
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1095
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1096
+ cachedTextDecoder.decode();
1097
+ numBytesDecoded = len;
1098
+ }
1099
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1100
+ }
1101
+
1102
+ const cachedTextEncoder = new TextEncoder();
1103
+
1104
+ if (!('encodeInto' in cachedTextEncoder)) {
1105
+ cachedTextEncoder.encodeInto = function (arg, view) {
1106
+ const buf = cachedTextEncoder.encode(arg);
1107
+ view.set(buf);
1108
+ return {
1109
+ read: arg.length,
1110
+ written: buf.length
1111
+ };
1112
+ };
1113
+ }
1114
+
1115
+ let WASM_VECTOR_LEN = 0;
1116
+
1117
+ let wasmModule, wasm;
1118
+ function __wbg_finalize_init(instance, module) {
1119
+ wasm = instance.exports;
1120
+ wasmModule = module;
1121
+ cachedDataViewMemory0 = null;
1122
+ cachedInt32ArrayMemory0 = null;
1123
+ cachedUint8ArrayMemory0 = null;
1124
+ wasm.__wbindgen_start();
1125
+ return wasm;
1126
+ }
1127
+
1128
+ async function __wbg_load(module, imports) {
1129
+ if (typeof Response === 'function' && module instanceof Response) {
1130
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1131
+ try {
1132
+ return await WebAssembly.instantiateStreaming(module, imports);
1133
+ } catch (e) {
1134
+ const validResponse = module.ok && expectedResponseType(module.type);
1135
+
1136
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1137
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1138
+
1139
+ } else { throw e; }
1140
+ }
1141
+ }
1142
+
1143
+ const bytes = await module.arrayBuffer();
1144
+ return await WebAssembly.instantiate(bytes, imports);
1145
+ } else {
1146
+ const instance = await WebAssembly.instantiate(module, imports);
1147
+
1148
+ if (instance instanceof WebAssembly.Instance) {
1149
+ return { instance, module };
1150
+ } else {
1151
+ return instance;
1152
+ }
1153
+ }
1154
+
1155
+ function expectedResponseType(type) {
1156
+ switch (type) {
1157
+ case 'basic': case 'cors': case 'default': return true;
1158
+ }
1159
+ return false;
1160
+ }
1161
+ }
1162
+
1163
+ function initSync(module) {
1164
+ if (wasm !== undefined) return wasm;
1165
+
1166
+
1167
+ if (module !== undefined) {
1168
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1169
+ ({module} = module)
1170
+ } else {
1171
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1172
+ }
1173
+ }
1174
+
1175
+ const imports = __wbg_get_imports();
1176
+ if (!(module instanceof WebAssembly.Module)) {
1177
+ module = new WebAssembly.Module(module);
1178
+ }
1179
+ const instance = new WebAssembly.Instance(module, imports);
1180
+ return __wbg_finalize_init(instance, module);
1181
+ }
1182
+
1183
+ async function __wbg_init(module_or_path) {
1184
+ if (wasm !== undefined) return wasm;
1185
+
1186
+
1187
+ if (module_or_path !== undefined) {
1188
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1189
+ ({module_or_path} = module_or_path)
1190
+ } else {
1191
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1192
+ }
1193
+ }
1194
+
1195
+ if (module_or_path === undefined) {
1196
+ module_or_path = new URL('qrcodes_bg.wasm', import.meta.url);
1197
+ }
1198
+ const imports = __wbg_get_imports();
1199
+
1200
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1201
+ module_or_path = fetch(module_or_path);
1202
+ }
1203
+
1204
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1205
+
1206
+ return __wbg_finalize_init(instance, module);
1207
+ }
1208
+
1209
+ export { initSync, __wbg_init as default };