@veaba/qrcode-wasm 0.0.3
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/LICENSE +21 -0
- package/README.md +320 -0
- package/dist/index.d.ts +170 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +347 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +137 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
- package/pkg/LICENSE +21 -0
- package/pkg/README.md +320 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Godpu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# @veaba/qrcode-wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly QRCode 生成器 - 基于 Rust 编译,提供优秀的 QRCode 生成性能。
|
|
4
|
+
|
|
5
|
+
## 简介
|
|
6
|
+
|
|
7
|
+
基于 Rust 实现并编译为 WebAssembly 的 QRCode 生成器,提供接近原生的执行速度。
|
|
8
|
+
|
|
9
|
+
与 `@veaba/qrcode-js` 提供**完全一致的 API**,方便在两个包之间无缝切换。
|
|
10
|
+
|
|
11
|
+
## 特性
|
|
12
|
+
|
|
13
|
+
- ⚡ **高性能** - Rust + WASM 提供接近原生的执行速度
|
|
14
|
+
- ⚡ **并行计算** - 支持多线程并行生成(需配置)
|
|
15
|
+
- 💾 **可选缓存** - LRU 缓存支持,重复文本性能提升 10 倍+
|
|
16
|
+
- 🎨 **丰富样式** - 支持 10+ 种个性样式
|
|
17
|
+
- 📦 **批量生成** - 支持批量异步生成
|
|
18
|
+
- 🖼️ **SVG 输出** - 生成矢量图形,清晰锐利
|
|
19
|
+
- 🔧 **TypeScript 支持** - 包含类型定义文件
|
|
20
|
+
- 🔄 **API 统一** - 与 `@veaba/qrcode-js` 完全一致的 API
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @veaba/qrcode-wasm
|
|
26
|
+
# 或
|
|
27
|
+
pnpm add @veaba/qrcode-wasm
|
|
28
|
+
# 或
|
|
29
|
+
yarn add @veaba/qrcode-wasm
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 使用方法
|
|
33
|
+
|
|
34
|
+
### 基础用法(统一 API)
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import init, { QRCodeCore, QRErrorCorrectLevel } from '@veaba/qrcode-wasm';
|
|
38
|
+
|
|
39
|
+
// 初始化 WASM(只需一次)
|
|
40
|
+
await init();
|
|
41
|
+
|
|
42
|
+
// 创建 QRCode 实例(与 qrcode-js 相同的 API)
|
|
43
|
+
const qr = new QRCodeCore('Hello World', QRErrorCorrectLevel.H);
|
|
44
|
+
|
|
45
|
+
// 获取 SVG
|
|
46
|
+
const svg = qr.toSVG(256);
|
|
47
|
+
|
|
48
|
+
// 插入到页面
|
|
49
|
+
document.getElementById('qrcode').innerHTML = svg;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 使用缓存(推荐)
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import init, {
|
|
56
|
+
generateRoundedQRCodeCached,
|
|
57
|
+
clearQRCodeCache,
|
|
58
|
+
getCacheStats
|
|
59
|
+
} from '@veaba/qrcode-wasm';
|
|
60
|
+
|
|
61
|
+
await init();
|
|
62
|
+
|
|
63
|
+
// 第一次生成会缓存
|
|
64
|
+
const svg1 = generateRoundedQRCodeCached('https://example.com', 256, 8);
|
|
65
|
+
|
|
66
|
+
// 第二次生成直接从缓存读取,速度提升 10 倍+
|
|
67
|
+
const svg2 = generateRoundedQRCodeCached('https://example.com', 256, 8);
|
|
68
|
+
|
|
69
|
+
// 查看缓存状态
|
|
70
|
+
console.log(getCacheStats()); // { size: 1, maxSize: 100, keys: [...] }
|
|
71
|
+
|
|
72
|
+
// 清空缓存
|
|
73
|
+
clearQRCodeCache();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 样式化二维码
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import init, {
|
|
80
|
+
generateWechatStyleQRCode,
|
|
81
|
+
generateDouyinStyleQRCode,
|
|
82
|
+
generateCyberpunkStyleQRCode
|
|
83
|
+
} from '@veaba/qrcode-wasm';
|
|
84
|
+
|
|
85
|
+
await init();
|
|
86
|
+
|
|
87
|
+
// 微信风格
|
|
88
|
+
const wechatQR = generateWechatStyleQRCode('https://weixin.qq.com', 256);
|
|
89
|
+
|
|
90
|
+
// 抖音风格
|
|
91
|
+
const douyinQR = generateDouyinStyleQRCode('https://douyin.com', 256);
|
|
92
|
+
|
|
93
|
+
// 赛博朋克风格
|
|
94
|
+
const cyberQR = generateCyberpunkStyleQRCode('https://example.com', 256);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 批量生成
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import init, { generateBatchQRCodes, generateBatchQRCodesCached } from '@veaba/qrcode-wasm';
|
|
101
|
+
|
|
102
|
+
await init();
|
|
103
|
+
|
|
104
|
+
const texts = [
|
|
105
|
+
'https://example.com/1',
|
|
106
|
+
'https://example.com/2',
|
|
107
|
+
// ... 更多
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
// 非缓存版本
|
|
111
|
+
const svgs = generateBatchQRCodes(texts, { size: 256 });
|
|
112
|
+
|
|
113
|
+
// 缓存版本
|
|
114
|
+
const svgsCached = generateBatchQRCodesCached(texts, { size: 256 });
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 异步生成
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import init, { generateQRCodeAsync, generateBatchAsync } from '@veaba/qrcode-wasm';
|
|
121
|
+
|
|
122
|
+
await init();
|
|
123
|
+
|
|
124
|
+
// 单个异步生成
|
|
125
|
+
const result = await generateQRCodeAsync('https://example.com', {
|
|
126
|
+
size: 256,
|
|
127
|
+
cache: true // 启用缓存
|
|
128
|
+
});
|
|
129
|
+
console.log(result.svg);
|
|
130
|
+
|
|
131
|
+
// 批量异步生成
|
|
132
|
+
const results = await generateBatchAsync(texts, {
|
|
133
|
+
size: 256,
|
|
134
|
+
cache: true
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## 底层 WASM API(可选)
|
|
139
|
+
|
|
140
|
+
如果需要更底层的控制,可以直接使用 WASM 原生 API:
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import init, { QRCodeWasm, CorrectLevel } from '@veaba/qrcode-wasm';
|
|
144
|
+
|
|
145
|
+
await init();
|
|
146
|
+
|
|
147
|
+
// 使用底层 WASM API
|
|
148
|
+
const qr = new QRCodeWasm();
|
|
149
|
+
qr.make_code('https://github.com/veaba/qrcodes');
|
|
150
|
+
const svg = qr.get_svg();
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 使用 QRCodeGenerator(可复用实例)
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import init, { QRCodeGenerator, CorrectLevel } from '@veaba/qrcode-wasm';
|
|
157
|
+
|
|
158
|
+
await init();
|
|
159
|
+
|
|
160
|
+
// 创建可复用的生成器
|
|
161
|
+
const gen = new QRCodeGenerator();
|
|
162
|
+
|
|
163
|
+
// 设置选项
|
|
164
|
+
gen.set_options(256, 256, CorrectLevel.H);
|
|
165
|
+
|
|
166
|
+
// 生成单个 QRCode
|
|
167
|
+
gen.generate('https://github.com/veaba/qrcodes/1');
|
|
168
|
+
const svg1 = gen.get_svg();
|
|
169
|
+
|
|
170
|
+
// 复用同一实例生成另一个(性能更好)
|
|
171
|
+
gen.generate('https://github.com/veaba/qrcodes/2');
|
|
172
|
+
const svg2 = gen.get_svg();
|
|
173
|
+
|
|
174
|
+
// 批量生成
|
|
175
|
+
const texts = ['url1', 'url2', 'url3'];
|
|
176
|
+
const svgs = gen.generate_batch(texts);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Canvas 渲染
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
import init, { CanvasRenderer } from '@veaba/qrcode-wasm';
|
|
183
|
+
|
|
184
|
+
await init();
|
|
185
|
+
|
|
186
|
+
// 创建 Canvas 渲染器
|
|
187
|
+
const renderer = new CanvasRenderer(256, 256);
|
|
188
|
+
|
|
189
|
+
// 设置颜色(RGBA)
|
|
190
|
+
renderer.set_colors(
|
|
191
|
+
0, 0, 0, 255, // 深色: 黑色
|
|
192
|
+
255, 255, 255, 255 // 浅色: 白色
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
// 渲染 QRCode
|
|
196
|
+
const pixelData = renderer.render('https://github.com/veaba/qrcodes', CorrectLevel.H);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## API
|
|
200
|
+
|
|
201
|
+
### 统一 API(与 qrcode-js 一致)
|
|
202
|
+
|
|
203
|
+
| 类/函数 | 说明 |
|
|
204
|
+
|---------|------|
|
|
205
|
+
| `QRCodeCore` | 核心 QRCode 类 |
|
|
206
|
+
| `QRErrorCorrectLevel` | 纠错级别枚举 |
|
|
207
|
+
| `generateRoundedQRCode` / `generateRoundedQRCodeCached` | 圆角二维码 |
|
|
208
|
+
| `generateGradientQRCode` / `generateGradientQRCodeCached` | 渐变二维码 |
|
|
209
|
+
| `generateWechatStyleQRCode` / `generateWechatStyleQRCodeCached` | 微信风格 |
|
|
210
|
+
| `generateDouyinStyleQRCode` / `generateDouyinStyleQRCodeCached` | 抖音风格 |
|
|
211
|
+
| `generateBatchQRCodes` / `generateBatchQRCodesCached` | 批量生成 |
|
|
212
|
+
| `generateQRCodeAsync` | 异步生成 |
|
|
213
|
+
| `getCachedQRCode` | 获取缓存 |
|
|
214
|
+
| `clearQRCodeCache` | 清空缓存 |
|
|
215
|
+
|
|
216
|
+
### 底层 WASM API
|
|
217
|
+
|
|
218
|
+
| 方法 | 说明 | 返回值 |
|
|
219
|
+
|------|------|--------|
|
|
220
|
+
| `new()` | 创建实例 | `QRCodeWasm` |
|
|
221
|
+
| `with_options(w, h, level)` | 带选项创建 | `QRCodeWasm` |
|
|
222
|
+
| `make_code(text)` | 生成 QRCode | `void` |
|
|
223
|
+
| `get_svg()` | 获取 SVG | `string` |
|
|
224
|
+
| `get_module_count()` | 获取模块数 | `number` |
|
|
225
|
+
| `get_modules_json()` | 获取模块数据 | `string` |
|
|
226
|
+
| `is_dark(row, col)` | 判断模块颜色 | `boolean` |
|
|
227
|
+
|
|
228
|
+
## 与 @veaba/qrcode-js 的对比
|
|
229
|
+
|
|
230
|
+
| 特性 | @veaba/qrcode-wasm | @veaba/qrcode-js |
|
|
231
|
+
|------|-------------------|------------------|
|
|
232
|
+
| 性能 | ⚡⚡⚡ 最快 | ⚡⚡ 快 |
|
|
233
|
+
| 包大小 | ~45KB | ~15KB |
|
|
234
|
+
| 初始化 | 需要异步 | 即时 |
|
|
235
|
+
| 兼容性 | 现代浏览器 | IE11+ |
|
|
236
|
+
| API | 统一 ✅ | 统一 ✅ |
|
|
237
|
+
|
|
238
|
+
选择 `@veaba/qrcode-wasm`:
|
|
239
|
+
- ✅ 追求极致性能
|
|
240
|
+
- ✅ 高频批量生成
|
|
241
|
+
- ✅ 现代浏览器环境
|
|
242
|
+
|
|
243
|
+
选择 `@veaba/qrcode-js`:
|
|
244
|
+
- ✅ 需要支持 IE11 等旧浏览器
|
|
245
|
+
- ✅ 对包大小敏感
|
|
246
|
+
- ✅ 不想处理 WASM 的异步初始化
|
|
247
|
+
|
|
248
|
+
## 性能对比
|
|
249
|
+
|
|
250
|
+
| 场景 | @veaba/qrcode-js | @veaba/qrcode-wasm | 提升 |
|
|
251
|
+
|------|------------------|-------------------|------|
|
|
252
|
+
| 单条生成 | ~9,000 ops/s | ~15,000 ops/s | **1.7x** |
|
|
253
|
+
| SVG 输出 | ~9,800 ops/s | ~17,000 ops/s | **1.7x** |
|
|
254
|
+
| 缓存命中 | ~500,000 ops/s | ~500,000 ops/s | 相同 |
|
|
255
|
+
|
|
256
|
+
*测试环境:Chrome 120, Intel i7-1165G7*
|
|
257
|
+
|
|
258
|
+
## 开发
|
|
259
|
+
|
|
260
|
+
### 环境要求
|
|
261
|
+
|
|
262
|
+
- Rust
|
|
263
|
+
- wasm-pack
|
|
264
|
+
- Node.js
|
|
265
|
+
|
|
266
|
+
### 构建
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# 安装 wasm-pack
|
|
270
|
+
cargo install wasm-pack
|
|
271
|
+
|
|
272
|
+
# 构建 WASM
|
|
273
|
+
wasm-pack build --target web
|
|
274
|
+
|
|
275
|
+
# 构建 Node.js 版本
|
|
276
|
+
wasm-pack build --target nodejs
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### 运行测试
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
# Rust 测试
|
|
283
|
+
cargo test
|
|
284
|
+
|
|
285
|
+
# TypeScript 测试
|
|
286
|
+
npm test
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 构建发布版本
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
# 优化构建
|
|
293
|
+
wasm-pack build --release --target web
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## 性能测试
|
|
297
|
+
|
|
298
|
+
基准测试已迁移到 `bench/frontend-benchmark`:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
cd bench/frontend-benchmark
|
|
302
|
+
node benchmark.cjs # 测试 qrcode-js
|
|
303
|
+
npx tsx wasm.benchmark.ts # 测试 qrcode-wasm
|
|
304
|
+
cargo run --bin benchmark # 测试 Rust 原生性能
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## 相关包
|
|
308
|
+
|
|
309
|
+
- `@veaba/qrcode-js` - 纯 JavaScript 版本(API 一致)
|
|
310
|
+
- `@veaba/qrcode-node` - Node.js 版本
|
|
311
|
+
- `@veaba/qrcode-bun` - Bun 运行时版本
|
|
312
|
+
- `@veaba/qrcode-shared` - 共享核心库
|
|
313
|
+
|
|
314
|
+
## License
|
|
315
|
+
|
|
316
|
+
MIT
|
|
317
|
+
|
|
318
|
+
## 历史迁移
|
|
319
|
+
|
|
320
|
+
- **2026-02-06**: 基准测试从 `packages/qrcode-wasm/benchmark/` 和 `packages/qrcode-wasm/src/bin/benchmark.rs` 迁移至 `bench/frontend-benchmark/`,保持包目录干净。
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @veaba/qrcode-wasm - WebAssembly QRCode generator
|
|
3
|
+
*
|
|
4
|
+
* This package provides a unified API that matches @veaba/qrcode-js.
|
|
5
|
+
* All functions use CamelCase naming convention for consistency.
|
|
6
|
+
*/
|
|
7
|
+
import init, { QRCodeGenerator, StyledQRCode, QRCodeStyle, CorrectLevel, init_thread_pool, is_parallel_supported, greet } from '../pkg/qrcodes.js';
|
|
8
|
+
export { CorrectLevel as QRErrorCorrectLevel };
|
|
9
|
+
export type { CorrectLevel as QRErrorCorrectLevelType };
|
|
10
|
+
export { QRCodeStyle, StyledQRCode };
|
|
11
|
+
export declare const QRMode: {
|
|
12
|
+
readonly MODE_8BIT_BYTE: 4;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* QRCode Core Class - Unified API with qrcode-js
|
|
16
|
+
*/
|
|
17
|
+
export declare class QRCodeCore {
|
|
18
|
+
private qr;
|
|
19
|
+
constructor(text: string, correctLevel?: CorrectLevel);
|
|
20
|
+
get moduleCount(): number;
|
|
21
|
+
getModuleCount(): number;
|
|
22
|
+
isDark(row: number, col: number): boolean;
|
|
23
|
+
toSVG(size?: number): string;
|
|
24
|
+
toStyledSVG(options?: StyledSVGOptions): string;
|
|
25
|
+
}
|
|
26
|
+
export declare const QRCode: typeof QRCodeCore;
|
|
27
|
+
export interface QRCodeOptions {
|
|
28
|
+
text: string;
|
|
29
|
+
correctLevel?: CorrectLevel;
|
|
30
|
+
size?: number;
|
|
31
|
+
colorDark?: string;
|
|
32
|
+
colorLight?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface StyledSVGOptions {
|
|
35
|
+
size?: number;
|
|
36
|
+
colorDark?: string;
|
|
37
|
+
colorLight?: string;
|
|
38
|
+
borderRadius?: number;
|
|
39
|
+
gradient?: {
|
|
40
|
+
color1: string;
|
|
41
|
+
color2: string;
|
|
42
|
+
} | null;
|
|
43
|
+
quietZone?: number;
|
|
44
|
+
logoRegions?: Array<{
|
|
45
|
+
row: number;
|
|
46
|
+
col: number;
|
|
47
|
+
size: number;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
export interface QRCodeResult {
|
|
51
|
+
text: string;
|
|
52
|
+
svg: string;
|
|
53
|
+
moduleCount: number;
|
|
54
|
+
}
|
|
55
|
+
export interface CacheOptions {
|
|
56
|
+
maxSize?: number;
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get cached QRCode (creates and caches if not exists)
|
|
61
|
+
*/
|
|
62
|
+
export declare function getCachedQRCode(text: string, correctLevel?: CorrectLevel): QRCodeCore;
|
|
63
|
+
/**
|
|
64
|
+
* Clear QRCode cache
|
|
65
|
+
*/
|
|
66
|
+
export declare function clearQRCodeCache(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get cache statistics
|
|
69
|
+
*/
|
|
70
|
+
export declare function getCacheStats(): {
|
|
71
|
+
size: number;
|
|
72
|
+
maxSize: number;
|
|
73
|
+
keys: string[];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Configure cache options
|
|
77
|
+
*/
|
|
78
|
+
export declare function configureCache(options: CacheOptions): void;
|
|
79
|
+
/**
|
|
80
|
+
* Generate rounded QRCode
|
|
81
|
+
*/
|
|
82
|
+
export declare function generateRoundedQRCode(text: string, size?: number, radius?: number): string;
|
|
83
|
+
/**
|
|
84
|
+
* Generate QRCode with logo area
|
|
85
|
+
*/
|
|
86
|
+
export declare function generateQRCodeWithLogoArea(text: string, size?: number, logoRatio?: number): string;
|
|
87
|
+
/**
|
|
88
|
+
* Generate gradient QRCode
|
|
89
|
+
*/
|
|
90
|
+
export declare function generateGradientQRCode(text: string, size?: number, color1?: string, color2?: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Generate WeChat style QRCode
|
|
93
|
+
*/
|
|
94
|
+
export declare function generateWechatStyleQRCode(text: string, size?: number): string;
|
|
95
|
+
/**
|
|
96
|
+
* Generate Douyin style QRCode
|
|
97
|
+
*/
|
|
98
|
+
export declare function generateDouyinStyleQRCode(text: string, size?: number): string;
|
|
99
|
+
/**
|
|
100
|
+
* Generate Alipay style QRCode
|
|
101
|
+
*/
|
|
102
|
+
export declare function generateAlipayStyleQRCode(text: string, size?: number): string;
|
|
103
|
+
/**
|
|
104
|
+
* Generate Xiaohongshu style QRCode
|
|
105
|
+
*/
|
|
106
|
+
export declare function generateXiaohongshuStyleQRCode(text: string, size?: number): string;
|
|
107
|
+
/**
|
|
108
|
+
* Generate Cyberpunk style QRCode
|
|
109
|
+
*/
|
|
110
|
+
export declare function generateCyberpunkStyleQRCode(text: string, size?: number): string;
|
|
111
|
+
/**
|
|
112
|
+
* Generate Retro style QRCode
|
|
113
|
+
*/
|
|
114
|
+
export declare function generateRetroStyleQRCode(text: string, size?: number): string;
|
|
115
|
+
/**
|
|
116
|
+
* Generate Minimal style QRCode
|
|
117
|
+
*/
|
|
118
|
+
export declare function generateMinimalStyleQRCode(text: string, size?: number): string;
|
|
119
|
+
export declare function generateRoundedQRCodeCached(text: string, size?: number, radius?: number): string;
|
|
120
|
+
export declare function generateQRCodeWithLogoAreaCached(text: string, size?: number, logoRatio?: number): string;
|
|
121
|
+
export declare function generateGradientQRCodeCached(text: string, size?: number, color1?: string, color2?: string): string;
|
|
122
|
+
export declare function generateWechatStyleQRCodeCached(text: string, size?: number): string;
|
|
123
|
+
export declare function generateDouyinStyleQRCodeCached(text: string, size?: number): string;
|
|
124
|
+
export declare function generateAlipayStyleQRCodeCached(text: string, size?: number): string;
|
|
125
|
+
export declare function generateXiaohongshuStyleQRCodeCached(text: string, size?: number): string;
|
|
126
|
+
export declare function generateCyberpunkStyleQRCodeCached(text: string, size?: number): string;
|
|
127
|
+
export declare function generateRetroStyleQRCodeCached(text: string, size?: number): string;
|
|
128
|
+
export declare function generateMinimalStyleQRCodeCached(text: string, size?: number): string;
|
|
129
|
+
/**
|
|
130
|
+
* Generate batch QRCodes
|
|
131
|
+
*/
|
|
132
|
+
export declare function generateBatchQRCodes(texts: string[], options?: Partial<QRCodeOptions>): string[];
|
|
133
|
+
/**
|
|
134
|
+
* Generate batch QRCodes (cached)
|
|
135
|
+
*/
|
|
136
|
+
export declare function generateBatchQRCodesCached(texts: string[], options?: Partial<QRCodeOptions> & {
|
|
137
|
+
styled?: boolean;
|
|
138
|
+
style?: StyledSVGOptions;
|
|
139
|
+
}): string[];
|
|
140
|
+
/**
|
|
141
|
+
* Generate QRCode asynchronously
|
|
142
|
+
*/
|
|
143
|
+
export declare function generateQRCodeAsync(text: string, options?: Partial<QRCodeOptions> & {
|
|
144
|
+
styled?: boolean;
|
|
145
|
+
style?: StyledSVGOptions;
|
|
146
|
+
cache?: boolean;
|
|
147
|
+
}): Promise<QRCodeResult>;
|
|
148
|
+
/**
|
|
149
|
+
* Generate batch QRCodes asynchronously
|
|
150
|
+
*/
|
|
151
|
+
export declare function generateBatchAsync(texts: string[], options?: Partial<QRCodeOptions> & {
|
|
152
|
+
styled?: boolean;
|
|
153
|
+
style?: StyledSVGOptions;
|
|
154
|
+
cache?: boolean;
|
|
155
|
+
}): Promise<QRCodeResult[]>;
|
|
156
|
+
export declare const generate_rounded_qrcode_alias: typeof generateRoundedQRCodeCached;
|
|
157
|
+
export declare const generate_qrcode_with_logo_area_alias: typeof generateQRCodeWithLogoAreaCached;
|
|
158
|
+
export declare const generate_gradient_qrcode_alias: typeof generateGradientQRCodeCached;
|
|
159
|
+
export declare const generate_wechat_style_qrcode_alias: typeof generateWechatStyleQRCodeCached;
|
|
160
|
+
export declare const generate_douyin_style_qrcode_alias: typeof generateDouyinStyleQRCodeCached;
|
|
161
|
+
export declare const generate_alipay_style_qrcode_alias: typeof generateAlipayStyleQRCodeCached;
|
|
162
|
+
export declare const generate_xiaohongshu_style_qrcode_alias: typeof generateXiaohongshuStyleQRCodeCached;
|
|
163
|
+
export declare const generate_cyberpunk_style_qrcode_alias: typeof generateCyberpunkStyleQRCodeCached;
|
|
164
|
+
export declare const generate_retro_style_qrcode_alias: typeof generateRetroStyleQRCodeCached;
|
|
165
|
+
export declare const generate_minimal_style_qrcode_alias: typeof generateMinimalStyleQRCodeCached;
|
|
166
|
+
export declare const VERSION = "0.2.0";
|
|
167
|
+
export declare function getVersionInfo(): string;
|
|
168
|
+
export { init, init_thread_pool, is_parallel_supported, QRCodeGenerator, greet, };
|
|
169
|
+
export default QRCodeCore;
|
|
170
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,IAAI,EAAE,EAGX,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EAgBZ,gBAAgB,EAChB,qBAAqB,EAGrB,KAAK,EACN,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,CAAC;AAC/C,YAAY,EAAE,YAAY,IAAI,uBAAuB,EAAE,CAAC;AAMxD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;AAGrC,eAAO,MAAM,MAAM;;CAAiC,CAAC;AAMrD;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,EAAE,CAAa;gBAEX,IAAI,EAAE,MAAM,EAAE,YAAY,GAAE,YAA6B;IAOrE,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,cAAc,IAAI,MAAM;IAIxB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzC,KAAK,CAAC,IAAI,GAAE,MAAY,GAAG,MAAM;IAIjC,WAAW,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM;CA0BpD;AAGD,eAAO,MAAM,MAAM,mBAAa,CAAC;AAMjC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IA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