@wirunrom/hqr-generate 0.2.23 → 0.3.11
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 +230 -151
- package/index.bundler.js +59 -34
- package/index.d.ts +29 -22
- package/index.web.js +61 -42
- package/package.json +66 -64
- package/pkg/bundler/LICENSE +21 -0
- package/pkg/bundler/README.md +230 -151
- package/pkg/bundler/hqr_generate.d.ts +2 -0
- package/pkg/bundler/hqr_generate.js +1 -1
- package/pkg/bundler/hqr_generate_bg.js +32 -0
- package/pkg/bundler/hqr_generate_bg.wasm +0 -0
- package/pkg/bundler/hqr_generate_bg.wasm.d.ts +3 -2
- package/pkg/bundler/package.json +1 -1
- package/pkg/web/LICENSE +21 -0
- package/pkg/web/README.md +230 -151
- package/pkg/web/hqr_generate.d.ts +5 -2
- package/pkg/web/hqr_generate.js +32 -0
- package/pkg/web/hqr_generate_bg.wasm +0 -0
- package/pkg/web/hqr_generate_bg.wasm.d.ts +3 -2
- package/pkg/web/package.json +1 -1
- package/react/index.d.ts +12 -17
- package/react/index.js +4 -91
- package/react/useQrDecodeFromImageData.d.ts +5 -0
- package/react/useQrDecodeFromImageData.js +47 -0
- package/react/useQrDecodeFromImageSrc.d.ts +6 -0
- package/react/useQrDecodeFromImageSrc.js +59 -0
- package/react/useQrPngBlobUrl.d.ts +6 -0
- package/react/useQrPngBlobUrl.js +52 -0
- package/react/useQrPngDataUrl.d.ts +6 -0
- package/react/useQrPngDataUrl.js +41 -0
package/package.json
CHANGED
|
@@ -1,64 +1,66 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wirunrom/hqr-generate",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/wirunrom/hqr-generate.git"
|
|
10
|
-
},
|
|
11
|
-
"homepage": "https://github.com/wirunrom/hqr-generate#readme",
|
|
12
|
-
"files": [
|
|
13
|
-
"pkg/**",
|
|
14
|
-
"index.web.js",
|
|
15
|
-
"index.bundler.js",
|
|
16
|
-
"index.d.ts",
|
|
17
|
-
"react/**",
|
|
18
|
-
"README.md",
|
|
19
|
-
"LICENSE"
|
|
20
|
-
],
|
|
21
|
-
"types": "./index.d.ts",
|
|
22
|
-
"main": "./index.bundler.js",
|
|
23
|
-
"module": "./index.bundler.js",
|
|
24
|
-
"exports": {
|
|
25
|
-
".": {
|
|
26
|
-
"types": "./index.d.ts",
|
|
27
|
-
"default": "./index.bundler.js"
|
|
28
|
-
},
|
|
29
|
-
"./react": {
|
|
30
|
-
"types": "./react/index.d.ts",
|
|
31
|
-
"default": "./react/index.js"
|
|
32
|
-
},
|
|
33
|
-
"./web": {
|
|
34
|
-
"types": "./index.d.ts",
|
|
35
|
-
"default": "./index.web.js"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"react": ">=17"
|
|
40
|
-
},
|
|
41
|
-
"peerDependenciesMeta": {
|
|
42
|
-
"react": {
|
|
43
|
-
"optional": true
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"clean": "rm -rf pkg",
|
|
48
|
-
"build:web": "wasm-pack build --target web --out-dir pkg/web",
|
|
49
|
-
"build:bundler": "wasm-pack build --target bundler --out-dir pkg/bundler",
|
|
50
|
-
"build": "npm run build:web && npm run build:bundler",
|
|
51
|
-
"prepack": "npm run clean && npm run build && rm -f pkg/web/.gitignore pkg/bundler/.gitignore",
|
|
52
|
-
"publish:npm": "npm publish --registry=https://registry.npmjs.org --access public",
|
|
53
|
-
"publish:github": "npm publish --registry=https://npm.pkg.github.com --userconfig .npmrc.github --access public"
|
|
54
|
-
},
|
|
55
|
-
"keywords": [
|
|
56
|
-
"qrcode",
|
|
57
|
-
"qr",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@wirunrom/hqr-generate",
|
|
3
|
+
"version": "0.3.11",
|
|
4
|
+
"description": "High-performance QR code generator and decoder powered by Rust + WASM",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/wirunrom/hqr-generate.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/wirunrom/hqr-generate#readme",
|
|
12
|
+
"files": [
|
|
13
|
+
"pkg/**",
|
|
14
|
+
"index.web.js",
|
|
15
|
+
"index.bundler.js",
|
|
16
|
+
"index.d.ts",
|
|
17
|
+
"react/**",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"types": "./index.d.ts",
|
|
22
|
+
"main": "./index.bundler.js",
|
|
23
|
+
"module": "./index.bundler.js",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"default": "./index.bundler.js"
|
|
28
|
+
},
|
|
29
|
+
"./react": {
|
|
30
|
+
"types": "./react/index.d.ts",
|
|
31
|
+
"default": "./react/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./web": {
|
|
34
|
+
"types": "./index.d.ts",
|
|
35
|
+
"default": "./index.web.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": ">=17"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"react": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"clean": "rm -rf pkg",
|
|
48
|
+
"build:web": "wasm-pack build --target web --out-dir pkg/web -- --features wasm,decode",
|
|
49
|
+
"build:bundler": "wasm-pack build --target bundler --out-dir pkg/bundler -- --features wasm,decode",
|
|
50
|
+
"build": "npm run build:web && npm run build:bundler",
|
|
51
|
+
"prepack": "npm run clean && npm run build && rm -f pkg/web/.gitignore pkg/bundler/.gitignore",
|
|
52
|
+
"publish:npm": "npm publish --registry=https://registry.npmjs.org --access public",
|
|
53
|
+
"publish:github": "npm publish --registry=https://npm.pkg.github.com --userconfig .npmrc.github --access public"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"qrcode",
|
|
57
|
+
"qr",
|
|
58
|
+
"qr-decode",
|
|
59
|
+
"qr-scanner",
|
|
60
|
+
"rust",
|
|
61
|
+
"wasm",
|
|
62
|
+
"react",
|
|
63
|
+
"png",
|
|
64
|
+
"performance"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wirunrom
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
package/pkg/bundler/README.md
CHANGED
|
@@ -1,151 +1,230 @@
|
|
|
1
|
-
# @wirunrom/hqr-generate
|
|
2
|
-
|
|
3
|
-
A
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
1
|
+
# @wirunrom/hqr-generate
|
|
2
|
+
|
|
3
|
+
A high-performance **QR Code generator and decoder** with
|
|
4
|
+
**black-and-white only output**, powered by **Rust + WebAssembly (WASM)**.
|
|
5
|
+
|
|
6
|
+
Supports both **QR generation** and **QR decoding (scan)** in modern web applications.
|
|
7
|
+
|
|
8
|
+
This library is designed with a **scan-reliability-first** mindset and a **frontend-first API**, making it easy to use in modern web applications without additional configuration.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- High-contrast **black & white only** output (maximum scan compatibility)
|
|
15
|
+
- Optimized for both **old and new mobile devices**
|
|
16
|
+
- Deterministic and consistent QR output
|
|
17
|
+
- Lightweight and fast (**Rust + WASM**)
|
|
18
|
+
- QR decoding (scan) from browser ImageData
|
|
19
|
+
- Supports:
|
|
20
|
+
- **PNG Data URL** (simple usage)
|
|
21
|
+
- **PNG raw bytes** (best performance, no Base64 overhead)
|
|
22
|
+
- Works out of the box with:
|
|
23
|
+
- Plain HTML / JavaScript
|
|
24
|
+
- React
|
|
25
|
+
- Next.js Client Component (Pages Router & App Router)
|
|
26
|
+
- Modern bundlers (Vite, Webpack, etc.)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @wirunrom/hqr-generate
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## API Reference (GenerateQR)
|
|
37
|
+
|
|
38
|
+
Generate a QR code and return a PNG Data URL.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
|
|
42
|
+
| Name | Type | Default | Description |
|
|
43
|
+
| ------ | -------------------------- | ------- | ---------------------------- |
|
|
44
|
+
| text | `string` | — | Text to encode |
|
|
45
|
+
| size | `number` | `320` | Image size in pixels |
|
|
46
|
+
| margin | `number` | `4` | Quiet zone (recommended ≥ 4) |
|
|
47
|
+
| ecc | `"L" \| "M" \| "Q" \| "H"` | `"Q"` | Error correction level |
|
|
48
|
+
|
|
49
|
+
## Basic Usage [Bundler / React / Next.js (Client)]
|
|
50
|
+
|
|
51
|
+
**Generate PNG Data URL**
|
|
52
|
+
|
|
53
|
+
Simple and widely compatible. Recommended for most use cases.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { qr_png_data_url } from "@wirunrom/hqr-generate";
|
|
57
|
+
|
|
58
|
+
const src = await qr_png_data_url("hello world", 320, 4, "Q");
|
|
59
|
+
|
|
60
|
+
<img src={src} alt="QR Code" />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Generate PNG Bytes (Best Performance)**
|
|
64
|
+
|
|
65
|
+
Using raw bytes avoids Base64 overhead and is more memory-efficient.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { qr_png_bytes } from "@wirunrom/hqr-generate";
|
|
69
|
+
|
|
70
|
+
const bytes = await qr_png_bytes("hello world", 320, 4, "Q");
|
|
71
|
+
|
|
72
|
+
const url = URL.createObjectURL(
|
|
73
|
+
new Blob([bytes], { type: "image/png" })
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
<img src={url} alt="QR Code" />
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Decode QR Code**
|
|
80
|
+
|
|
81
|
+
Decode a QR code from browser ImageData (Canvas / camera / image upload friendly).
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { qr_decode_from_image } from "@wirunrom/hqr-generate";
|
|
85
|
+
|
|
86
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
87
|
+
const text = await qr_decode_from_image(imageData);
|
|
88
|
+
|
|
89
|
+
console.log(text);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Decode runs entirely in WASM and does not require server-side processing.
|
|
93
|
+
|
|
94
|
+
## React Hook Helper (/react)
|
|
95
|
+
|
|
96
|
+
For React or Next.js applications, the library provides idiomatic React hooks that manage async state automatically.
|
|
97
|
+
|
|
98
|
+
**useQrPngDataUrl**
|
|
99
|
+
|
|
100
|
+
Generates a PNG Data URL and updates automatically when inputs change.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { useQrPngDataUrl } from "@wirunrom/hqr-generate/react";
|
|
104
|
+
|
|
105
|
+
function QR() {
|
|
106
|
+
const src = useQrPngDataUrl("hello world", {
|
|
107
|
+
size: 320,
|
|
108
|
+
margin: 4,
|
|
109
|
+
ecc: "Q",
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (!src) return null;
|
|
113
|
+
return <img src={src} alt="QR Code" />;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**useQrPngBlobUrl**
|
|
118
|
+
|
|
119
|
+
Generates a Blob URL instead of a Base64 Data URL.
|
|
120
|
+
Recommended for larger QR codes or frequent updates.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { useQrPngBlobUrl } from "@wirunrom/hqr-generate/react";
|
|
124
|
+
|
|
125
|
+
function QR() {
|
|
126
|
+
const src = useQrPngBlobUrl("hello world", {
|
|
127
|
+
size: 320,
|
|
128
|
+
margin: 4,
|
|
129
|
+
ecc: "Q",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (!src) return null;
|
|
133
|
+
return <img src={src} alt="QR Code" />;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**useQrDecodeFromImageData**
|
|
138
|
+
|
|
139
|
+
Decode a QR code from browser ImageData.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { useQrDecodeFromImageData } from "@wirunrom/hqr-generate/react";
|
|
143
|
+
|
|
144
|
+
function Scanner({ image }: { image: ImageData | null }) {
|
|
145
|
+
const { text, loading, error } = useQrDecodeFromImageData(image);
|
|
146
|
+
|
|
147
|
+
if (loading) return <div>Scanning…</div>;
|
|
148
|
+
if (error) return <div>Error</div>;
|
|
149
|
+
if (!text) return null;
|
|
150
|
+
|
|
151
|
+
return <div>QR: {text}</div>;
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Parameters
|
|
156
|
+
|
|
157
|
+
| Name | Type | Description |
|
|
158
|
+
| ----- | ----------- | ------------------------------------------- |
|
|
159
|
+
| image | `ImageData` | RGBA image data from Canvas or Camera frame |
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
|
|
163
|
+
- `Promise<string>`
|
|
164
|
+
- Resolves with decoded QR text
|
|
165
|
+
- Rejects if no QR code is detected or image is invalid
|
|
166
|
+
|
|
167
|
+
Notes
|
|
168
|
+
|
|
169
|
+
- Input must be RGBA ImageData
|
|
170
|
+
- Decode runs entirely in WASM
|
|
171
|
+
- No server or backend required
|
|
172
|
+
- Best results with:
|
|
173
|
+
- High-contrast QR codes
|
|
174
|
+
- Minimal blur
|
|
175
|
+
- Proper quiet zone
|
|
176
|
+
|
|
177
|
+
**useQrDecodeFromImageSrc**
|
|
178
|
+
|
|
179
|
+
Decode a QR code from your image path.
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { useQrDecodeFromImageSrc } from "@wirunrom/hqr-generate/react";
|
|
183
|
+
|
|
184
|
+
function DecodeQR({ imagePath }: { imagePath: string | null }) {
|
|
185
|
+
const { text } = useQrDecodeFromImageSrc(imagePath);
|
|
186
|
+
|
|
187
|
+
if (!text) return null;
|
|
188
|
+
|
|
189
|
+
return <div>Decode QR: {text}</div>;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Parameters
|
|
194
|
+
|
|
195
|
+
| Name | Type | Description |
|
|
196
|
+
| ---- | -------- | --------------- |
|
|
197
|
+
| src | `string` | Your image path |
|
|
198
|
+
|
|
199
|
+
Returns
|
|
200
|
+
|
|
201
|
+
- `Promise<string>`
|
|
202
|
+
- Resolves with decoded QR text
|
|
203
|
+
|
|
204
|
+
## Plain HTML / No Bundler (/web)
|
|
205
|
+
|
|
206
|
+
Use this entry when working with static HTML, CDN, or environments without a bundler.
|
|
207
|
+
|
|
208
|
+
```html
|
|
209
|
+
<script type="module">
|
|
210
|
+
import {
|
|
211
|
+
qr_png_bytes,
|
|
212
|
+
qr_png_data_url,
|
|
213
|
+
qr_decode_from_image_data,
|
|
214
|
+
} from "@wirunrom/hqr-generate/web";
|
|
215
|
+
|
|
216
|
+
const src = await qr_png_data_url("hello world", 320, 4, "Q");
|
|
217
|
+
document.getElementById("qr").src = src;
|
|
218
|
+
|
|
219
|
+
// decode example (canvas)
|
|
220
|
+
const canvas = document.getElementById("c");
|
|
221
|
+
const ctx = canvas.getContext("2d");
|
|
222
|
+
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
223
|
+
|
|
224
|
+
const text = await qr_decode_from_image_data(imageData);
|
|
225
|
+
console.log(text);
|
|
226
|
+
</script>
|
|
227
|
+
|
|
228
|
+
<img id="qr" />
|
|
229
|
+
<canvas id="c" hidden></canvas>
|
|
230
|
+
```
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
export function qr_decode_from_rgba(width: number, height: number, rgba: Uint8Array): string;
|
|
5
|
+
|
|
4
6
|
export function qr_png_bytes(text: string, size: number, margin: number, ecc: number): Uint8Array;
|
|
5
7
|
|
|
6
8
|
export function qr_png_data_url(text: string, size: number, margin: number, ecc: number): string;
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {number} width
|
|
3
|
+
* @param {number} height
|
|
4
|
+
* @param {Uint8Array} rgba
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function qr_decode_from_rgba(width, height, rgba) {
|
|
8
|
+
let deferred2_0;
|
|
9
|
+
let deferred2_1;
|
|
10
|
+
try {
|
|
11
|
+
const ret = wasm.qr_decode_from_rgba(width, height, rgba);
|
|
12
|
+
var ptr1 = ret[0];
|
|
13
|
+
var len1 = ret[1];
|
|
14
|
+
if (ret[3]) {
|
|
15
|
+
ptr1 = 0; len1 = 0;
|
|
16
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
17
|
+
}
|
|
18
|
+
deferred2_0 = ptr1;
|
|
19
|
+
deferred2_1 = len1;
|
|
20
|
+
return getStringFromWasm0(ptr1, len1);
|
|
21
|
+
} finally {
|
|
22
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
1
26
|
/**
|
|
2
27
|
* @param {string} text
|
|
3
28
|
* @param {number} size
|
|
@@ -45,10 +70,17 @@ export function qr_png_data_url(text, size, margin, ecc) {
|
|
|
45
70
|
export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
|
|
46
71
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
47
72
|
}
|
|
73
|
+
export function __wbg_length_32ed9a279acd054c(arg0) {
|
|
74
|
+
const ret = arg0.length;
|
|
75
|
+
return ret;
|
|
76
|
+
}
|
|
48
77
|
export function __wbg_new_from_slice_a3d2629dc1826784(arg0, arg1) {
|
|
49
78
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
50
79
|
return ret;
|
|
51
80
|
}
|
|
81
|
+
export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
|
|
82
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
83
|
+
}
|
|
52
84
|
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
53
85
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
54
86
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
Binary file
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const qr_decode_from_rgba: (a: number, b: number, c: any) => [number, number, number, number];
|
|
4
5
|
export const qr_png_bytes: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
5
6
|
export const qr_png_data_url: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
6
7
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
7
|
-
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
|
-
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
9
8
|
export const __externref_table_dealloc: (a: number) => void;
|
|
10
9
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
11
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
11
12
|
export const __wbindgen_start: () => void;
|
package/pkg/bundler/package.json
CHANGED
package/pkg/web/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Wirunrom
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|