@asaddevworld/styled-qr 0.0.0-stage → 0.1.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.
- package/LICENSE +20 -0
- package/README.md +102 -2
- package/lib/module/StyledQR.js +234 -0
- package/lib/module/StyledQR.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/matrix.js +41 -0
- package/lib/module/matrix.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/svg.js +87 -0
- package/lib/module/svg.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useQRMatrix.js +9 -0
- package/lib/module/useQRMatrix.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/StyledQR.d.ts +4 -0
- package/lib/typescript/src/StyledQR.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/matrix.d.ts +14 -0
- package/lib/typescript/src/matrix.d.ts.map +1 -0
- package/lib/typescript/src/svg.d.ts +16 -0
- package/lib/typescript/src/svg.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +58 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/useQRMatrix.d.ts +4 -0
- package/lib/typescript/src/useQRMatrix.d.ts.map +1 -0
- package/package.json +166 -4
- package/src/StyledQR.tsx +301 -0
- package/src/index.tsx +14 -0
- package/src/matrix.ts +49 -0
- package/src/svg.ts +125 -0
- package/src/types.ts +57 -0
- package/src/useQRMatrix.ts +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Asad Ali
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# rn-styled-qr
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Styled QR codes for React Native, drawn with Skia. Pick a dot style and an eye style, a solid colour or a gradient, drop a logo in the middle with a clear zone, animate the reveal, and export the result as a PNG or an SVG string. The matrix comes from the `qrcode` encoder; everything you see is this package.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
https://github.com/user-attachments/assets/67200e92-426b-419e-beed-172fc7a4fb54
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
_Demo recorded on the iOS Simulator from the example app: [docs/demo.mp4](docs/demo.mp4)._
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @asaddevworld/styled-qr @shopify/react-native-skia react-native-reanimated react-native-worklets
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
With Expo:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx expo install @asaddevworld/styled-qr @shopify/react-native-skia react-native-reanimated react-native-worklets
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Requires React Native 0.76 or newer, Skia 2 and Reanimated 4.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { StyledQR } from '@asaddevworld/styled-qr';
|
|
31
|
+
|
|
32
|
+
<StyledQR
|
|
33
|
+
value="https://example.com"
|
|
34
|
+
size={260}
|
|
35
|
+
dotStyle="rounded"
|
|
36
|
+
eyeStyle="rounded"
|
|
37
|
+
gradient={{ colors: ['#0EA5E9', '#6366F1'] }}
|
|
38
|
+
backgroundColor="#FFFFFF"
|
|
39
|
+
backgroundRadius={20}
|
|
40
|
+
logo={{ image: skImage, size: 0.2 }}
|
|
41
|
+
animate
|
|
42
|
+
/>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Export:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
const ref = useRef<StyledQRHandle>(null);
|
|
49
|
+
<StyledQR ref={ref} value="..." />
|
|
50
|
+
|
|
51
|
+
const png = ref.current?.toPNG(); // base64 PNG at the device pixel ratio
|
|
52
|
+
const svg = ref.current?.toSVG(); // SVG markup, same geometry and colours
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
### `StyledQR` props
|
|
58
|
+
|
|
59
|
+
| prop | type | default | description |
|
|
60
|
+
|---|---|---|---|
|
|
61
|
+
| `value` | `string` | required | Text or URL to encode. |
|
|
62
|
+
| `size` | `number` | `240` | Width and height in px. |
|
|
63
|
+
| `errorCorrection` | `'L' \| 'M' \| 'Q' \| 'H'` | `'M'` | Forced to `'H'` when a logo is set. |
|
|
64
|
+
| `dotStyle` | `'square' \| 'rounded' \| 'dots'` | `'square'` | Shape of data modules. |
|
|
65
|
+
| `eyeStyle` | `'square' \| 'rounded' \| 'circle'` | `'square'` | Shape of the three finder patterns. |
|
|
66
|
+
| `color` | `string` | `'#000000'` | Module colour. |
|
|
67
|
+
| `gradient` | `{ colors, start?, end? }` | | Linear gradient over the modules; `start` and `end` are 0..1 fractions. |
|
|
68
|
+
| `backgroundColor` | `string` | `'#FFFFFF'` | `'transparent'` for none. |
|
|
69
|
+
| `backgroundRadius` | `number` | `0` | Corner radius of the background. |
|
|
70
|
+
| `logo` | `{ image: SkImage, size?, padding?, radius? }` | | Centred logo with a clear zone. `size` is a fraction of the QR size, default 0.22. |
|
|
71
|
+
| `quietZone` | `number` | `2` | Margin in modules. |
|
|
72
|
+
| `animate` | `boolean` | `false` | Ripple reveal on mount and on value or style change. |
|
|
73
|
+
|
|
74
|
+
### Ref methods
|
|
75
|
+
|
|
76
|
+
`toPNG()` returns a base64 PNG, or null before the first draw. `toSVG()` returns SVG markup (logo not included).
|
|
77
|
+
|
|
78
|
+
### Helpers
|
|
79
|
+
|
|
80
|
+
`useQRMatrix(value, errorCorrection)`, `createMatrix`, `isEye`, `geometry`, and `qrToSVG(matrix, options)` for use without the component.
|
|
81
|
+
|
|
82
|
+
## Behaviour notes
|
|
83
|
+
|
|
84
|
+
- Styled modules keep their centres, so scanners read them the same as plain squares. Keep the logo at 0.25 of the size or less.
|
|
85
|
+
- With a logo the modules under its clear zone are skipped, and error correction is set to H so the code stays readable.
|
|
86
|
+
- The reveal grows from the centre over 650 ms. Reduced motion skips it.
|
|
87
|
+
|
|
88
|
+
## Example app
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
yarn
|
|
92
|
+
yarn example ios
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
One screen: a text field, dot and eye styles, five colour presets, logo and animation toggles, Share PNG and Copy SVG.
|
|
96
|
+
|
|
97
|
+
## Credits
|
|
98
|
+
|
|
99
|
+
Inspired by the QR code demos by Enzo Mangano at reactiive.io. Implemented from scratch for this package.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT © Asad Ali
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { Canvas, Group, Image, LinearGradient, Path, RoundedRect, Skia, useCanvasRef, vec } from '@shopify/react-native-skia';
|
|
6
|
+
import { Easing, ReduceMotion, useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
7
|
+
import { createMatrix, geometry, isEye } from "./matrix.js";
|
|
8
|
+
import { qrToSVG } from "./svg.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
function buildScene(props) {
|
|
11
|
+
const {
|
|
12
|
+
value,
|
|
13
|
+
size,
|
|
14
|
+
errorCorrection,
|
|
15
|
+
dotStyle,
|
|
16
|
+
eyeStyle,
|
|
17
|
+
quietZone,
|
|
18
|
+
logo
|
|
19
|
+
} = props;
|
|
20
|
+
const matrix = createMatrix(value, logo ? 'H' : errorCorrection);
|
|
21
|
+
const {
|
|
22
|
+
cell,
|
|
23
|
+
offset
|
|
24
|
+
} = geometry(matrix, size, quietZone);
|
|
25
|
+
const logoSize = logo ? size * (logo.size ?? 0.22) : 0;
|
|
26
|
+
const pad = logo ? logo.padding ?? 6 : 0;
|
|
27
|
+
const logoRect = logo ? {
|
|
28
|
+
x: (size - logoSize) / 2 - pad,
|
|
29
|
+
y: (size - logoSize) / 2 - pad,
|
|
30
|
+
width: logoSize + pad * 2,
|
|
31
|
+
height: logoSize + pad * 2
|
|
32
|
+
} : null;
|
|
33
|
+
const data = Skia.PathBuilder.Make();
|
|
34
|
+
for (let r = 0; r < matrix.size; r++) {
|
|
35
|
+
for (let c = 0; c < matrix.size; c++) {
|
|
36
|
+
if (!matrix.modules[r]?.[c] || isEye(r, c, matrix.size)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const x = offset + c * cell;
|
|
40
|
+
const y = offset + r * cell;
|
|
41
|
+
if (logoRect) {
|
|
42
|
+
const cx = x + cell / 2;
|
|
43
|
+
const cy = y + cell / 2;
|
|
44
|
+
if (cx > logoRect.x && cx < logoRect.x + logoRect.width && cy > logoRect.y && cy < logoRect.y + logoRect.height) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (dotStyle === 'dots') {
|
|
49
|
+
data.addCircle(x + cell / 2, y + cell / 2, cell * 0.4);
|
|
50
|
+
} else if (dotStyle === 'rounded') {
|
|
51
|
+
data.addRRect(Skia.RRectXY({
|
|
52
|
+
x: x + cell * 0.05,
|
|
53
|
+
y: y + cell * 0.05,
|
|
54
|
+
width: cell * 0.9,
|
|
55
|
+
height: cell * 0.9
|
|
56
|
+
}, cell * 0.3, cell * 0.3));
|
|
57
|
+
} else {
|
|
58
|
+
data.addRect({
|
|
59
|
+
x,
|
|
60
|
+
y,
|
|
61
|
+
width: cell,
|
|
62
|
+
height: cell
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const eyes = Skia.PathBuilder.Make();
|
|
68
|
+
const corners = [[0, 0], [0, matrix.size - 7], [matrix.size - 7, 0]];
|
|
69
|
+
for (const [r, c] of corners) {
|
|
70
|
+
const x = offset + c * cell;
|
|
71
|
+
const y = offset + r * cell;
|
|
72
|
+
const outer = cell * 7;
|
|
73
|
+
const ring = cell * 5;
|
|
74
|
+
const inner = cell * 3;
|
|
75
|
+
if (eyeStyle === 'circle') {
|
|
76
|
+
eyes.addCircle(x + outer / 2, y + outer / 2, outer / 2);
|
|
77
|
+
eyes.addCircle(x + outer / 2, y + outer / 2, ring / 2);
|
|
78
|
+
eyes.addCircle(x + outer / 2, y + outer / 2, inner / 2);
|
|
79
|
+
} else {
|
|
80
|
+
const radius = eyeStyle === 'rounded' ? cell * 2 : 0;
|
|
81
|
+
const ringRadius = eyeStyle === 'rounded' ? cell * 1.2 : 0;
|
|
82
|
+
const innerRadius = eyeStyle === 'rounded' ? cell * 0.8 : 0;
|
|
83
|
+
eyes.addRRect(Skia.RRectXY({
|
|
84
|
+
x,
|
|
85
|
+
y,
|
|
86
|
+
width: outer,
|
|
87
|
+
height: outer
|
|
88
|
+
}, radius, radius));
|
|
89
|
+
eyes.addRRect(Skia.RRectXY({
|
|
90
|
+
x: x + cell,
|
|
91
|
+
y: y + cell,
|
|
92
|
+
width: ring,
|
|
93
|
+
height: ring
|
|
94
|
+
}, ringRadius, ringRadius));
|
|
95
|
+
eyes.addRRect(Skia.RRectXY({
|
|
96
|
+
x: x + cell * 2,
|
|
97
|
+
y: y + cell * 2,
|
|
98
|
+
width: inner,
|
|
99
|
+
height: inner
|
|
100
|
+
}, innerRadius, innerRadius));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// The eyes path is drawn even-odd: outer square minus the ring, plus the inner square.
|
|
104
|
+
return {
|
|
105
|
+
data: data.build(),
|
|
106
|
+
eyes: eyes.build(),
|
|
107
|
+
logoRect
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A QR code drawn with Skia, styled, with an optional logo and an animated reveal. */
|
|
112
|
+
export const StyledQR = /*#__PURE__*/forwardRef(function StyledQR({
|
|
113
|
+
value,
|
|
114
|
+
size = 240,
|
|
115
|
+
errorCorrection = 'M',
|
|
116
|
+
dotStyle = 'square',
|
|
117
|
+
eyeStyle = 'square',
|
|
118
|
+
color = '#000000',
|
|
119
|
+
gradient,
|
|
120
|
+
backgroundColor = '#FFFFFF',
|
|
121
|
+
backgroundRadius = 0,
|
|
122
|
+
logo,
|
|
123
|
+
quietZone = 2,
|
|
124
|
+
animate = false,
|
|
125
|
+
accessibilityLabel
|
|
126
|
+
}, ref) {
|
|
127
|
+
const canvasRef = useCanvasRef();
|
|
128
|
+
const scene = useMemo(() => buildScene({
|
|
129
|
+
value,
|
|
130
|
+
size,
|
|
131
|
+
errorCorrection,
|
|
132
|
+
dotStyle,
|
|
133
|
+
eyeStyle,
|
|
134
|
+
quietZone,
|
|
135
|
+
logo
|
|
136
|
+
}), [value, size, errorCorrection, dotStyle, eyeStyle, quietZone, logo]);
|
|
137
|
+
const reveal = useSharedValue(animate ? 0 : 1);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!animate) {
|
|
140
|
+
reveal.value = 1;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
reveal.value = 0;
|
|
144
|
+
reveal.value = withTiming(1, {
|
|
145
|
+
duration: 650,
|
|
146
|
+
easing: Easing.out(Easing.cubic),
|
|
147
|
+
reduceMotion: ReduceMotion.System
|
|
148
|
+
});
|
|
149
|
+
}, [animate, value, dotStyle, eyeStyle, reveal]);
|
|
150
|
+
const clip = useDerivedValue(() => {
|
|
151
|
+
const radius = reveal.value * size * Math.SQRT2 / 2 + 1;
|
|
152
|
+
return Skia.PathBuilder.Make().addCircle(size / 2, size / 2, radius).build();
|
|
153
|
+
});
|
|
154
|
+
useImperativeHandle(ref, () => ({
|
|
155
|
+
toPNG: () => canvasRef.current?.makeImageSnapshot()?.encodeToBase64() ?? null,
|
|
156
|
+
toSVG: () => qrToSVG(createMatrix(value, logo ? 'H' : errorCorrection), {
|
|
157
|
+
size,
|
|
158
|
+
quietZone,
|
|
159
|
+
dotStyle,
|
|
160
|
+
eyeStyle,
|
|
161
|
+
color,
|
|
162
|
+
gradient,
|
|
163
|
+
backgroundColor,
|
|
164
|
+
backgroundRadius,
|
|
165
|
+
logoHole: logo ? (logo.size ?? 0.22) + (logo.padding ?? 6) * 2 / size : 0
|
|
166
|
+
})
|
|
167
|
+
}), [canvasRef, value, logo, errorCorrection, size, quietZone, dotStyle, eyeStyle, color, gradient, backgroundColor, backgroundRadius]);
|
|
168
|
+
const start = gradient?.start ?? {
|
|
169
|
+
x: 0,
|
|
170
|
+
y: 0
|
|
171
|
+
};
|
|
172
|
+
const end = gradient?.end ?? {
|
|
173
|
+
x: 1,
|
|
174
|
+
y: 1
|
|
175
|
+
};
|
|
176
|
+
const paint = gradient ? /*#__PURE__*/_jsx(LinearGradient, {
|
|
177
|
+
start: vec(start.x * size, start.y * size),
|
|
178
|
+
end: vec(end.x * size, end.y * size),
|
|
179
|
+
colors: gradient.colors
|
|
180
|
+
}) : null;
|
|
181
|
+
return /*#__PURE__*/_jsx(View, {
|
|
182
|
+
style: {
|
|
183
|
+
width: size,
|
|
184
|
+
height: size
|
|
185
|
+
},
|
|
186
|
+
accessible: true,
|
|
187
|
+
accessibilityRole: "image",
|
|
188
|
+
accessibilityLabel: accessibilityLabel ?? `QR code for ${value}`,
|
|
189
|
+
children: /*#__PURE__*/_jsxs(Canvas, {
|
|
190
|
+
ref: canvasRef,
|
|
191
|
+
style: {
|
|
192
|
+
width: size,
|
|
193
|
+
height: size
|
|
194
|
+
},
|
|
195
|
+
children: [backgroundColor !== 'transparent' ? /*#__PURE__*/_jsx(RoundedRect, {
|
|
196
|
+
x: 0,
|
|
197
|
+
y: 0,
|
|
198
|
+
width: size,
|
|
199
|
+
height: size,
|
|
200
|
+
r: backgroundRadius,
|
|
201
|
+
color: backgroundColor
|
|
202
|
+
}) : null, /*#__PURE__*/_jsxs(Group, {
|
|
203
|
+
clip: clip,
|
|
204
|
+
children: [/*#__PURE__*/_jsx(Path, {
|
|
205
|
+
path: scene.data,
|
|
206
|
+
color: color,
|
|
207
|
+
children: paint
|
|
208
|
+
}), /*#__PURE__*/_jsx(Path, {
|
|
209
|
+
path: scene.eyes,
|
|
210
|
+
color: color,
|
|
211
|
+
fillType: "evenOdd",
|
|
212
|
+
children: paint
|
|
213
|
+
})]
|
|
214
|
+
}), logo && scene.logoRect ? /*#__PURE__*/_jsxs(Group, {
|
|
215
|
+
children: [/*#__PURE__*/_jsx(RoundedRect, {
|
|
216
|
+
x: scene.logoRect.x,
|
|
217
|
+
y: scene.logoRect.y,
|
|
218
|
+
width: scene.logoRect.width,
|
|
219
|
+
height: scene.logoRect.height,
|
|
220
|
+
r: logo.radius ?? 8,
|
|
221
|
+
color: backgroundColor === 'transparent' ? '#FFFFFF' : backgroundColor
|
|
222
|
+
}), /*#__PURE__*/_jsx(Image, {
|
|
223
|
+
image: logo.image,
|
|
224
|
+
x: scene.logoRect.x + (logo.padding ?? 6),
|
|
225
|
+
y: scene.logoRect.y + (logo.padding ?? 6),
|
|
226
|
+
width: scene.logoRect.width - (logo.padding ?? 6) * 2,
|
|
227
|
+
height: scene.logoRect.height - (logo.padding ?? 6) * 2,
|
|
228
|
+
fit: "contain"
|
|
229
|
+
})]
|
|
230
|
+
}) : null]
|
|
231
|
+
})
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
//# sourceMappingURL=StyledQR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useEffect","useImperativeHandle","useMemo","View","Canvas","Group","Image","LinearGradient","Path","RoundedRect","Skia","useCanvasRef","vec","Easing","ReduceMotion","useDerivedValue","useSharedValue","withTiming","createMatrix","geometry","isEye","qrToSVG","jsx","_jsx","jsxs","_jsxs","buildScene","props","value","size","errorCorrection","dotStyle","eyeStyle","quietZone","logo","matrix","cell","offset","logoSize","pad","padding","logoRect","x","y","width","height","data","PathBuilder","Make","r","c","modules","cx","cy","addCircle","addRRect","RRectXY","addRect","eyes","corners","outer","ring","inner","radius","ringRadius","innerRadius","build","StyledQR","color","gradient","backgroundColor","backgroundRadius","animate","accessibilityLabel","ref","canvasRef","scene","reveal","duration","easing","out","cubic","reduceMotion","System","clip","Math","SQRT2","toPNG","current","makeImageSnapshot","encodeToBase64","toSVG","logoHole","start","end","paint","colors","style","accessible","accessibilityRole","children","path","fillType","image","fit"],"sourceRoot":"../../src","sources":["StyledQR.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,mBAAmB,EAAEC,OAAO,QAAQ,OAAO;AAC3E,SAASC,I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d,CAAC;MAAA,CACG,CAAC,GACN,IAAI;IAAA,CACF;EAAC,CACL,CAAC;AAEX,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyledQR","useQRMatrix","createMatrix","isEye","geometry","qrToSVG"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,eAAY;AACrC,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,YAAY,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,aAAU;AACxD,SAASC,OAAO,QAAyB,UAAO","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import QRCode from 'qrcode';
|
|
4
|
+
/** Encode text into a module grid. */
|
|
5
|
+
export function createMatrix(value, errorCorrection = 'M') {
|
|
6
|
+
const code = QRCode.create(value || ' ', {
|
|
7
|
+
errorCorrectionLevel: errorCorrection
|
|
8
|
+
});
|
|
9
|
+
const size = code.modules.size;
|
|
10
|
+
const data = code.modules.data;
|
|
11
|
+
const modules = [];
|
|
12
|
+
for (let r = 0; r < size; r++) {
|
|
13
|
+
const row = [];
|
|
14
|
+
for (let c = 0; c < size; c++) {
|
|
15
|
+
row.push(data[r * size + c] === 1);
|
|
16
|
+
}
|
|
17
|
+
modules.push(row);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
size,
|
|
21
|
+
modules
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** True when (row, col) is inside one of the three finder patterns. */
|
|
26
|
+
export function isEye(row, col, size) {
|
|
27
|
+
const inTopLeft = row < 7 && col < 7;
|
|
28
|
+
const inTopRight = row < 7 && col >= size - 7;
|
|
29
|
+
const inBottomLeft = row >= size - 7 && col < 7;
|
|
30
|
+
return inTopLeft || inTopRight || inBottomLeft;
|
|
31
|
+
}
|
|
32
|
+
export function geometry(matrix, pixelSize, quietZone) {
|
|
33
|
+
const total = matrix.size + quietZone * 2;
|
|
34
|
+
const cell = pixelSize / total;
|
|
35
|
+
return {
|
|
36
|
+
cell,
|
|
37
|
+
offset: quietZone * cell,
|
|
38
|
+
size: matrix.size
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=matrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["QRCode","createMatrix","value","errorCorrection","code","create","errorCorrectionLevel","size","modules","data","r","row","c","push","isEye","col","inTopLeft","inTopRight","inBottomLeft","geometry","matrix","pixelSize","quietZone","total","cell","offset"],"sourceRoot":"../../src","sources":["matrix.ts"],"mappings":";;AAAA,OAAOA,MAAM,MAAM,QAAQ;AAG3B;AACA,OAAO,SAASC,YAAYA,CAC1BC,KAAa,EACbC,eAAgC,GAAG,GAAG,EAC5B;EACV,MAAMC,IAAI,GAAGJ,MAAM,CAACK,MAAM,CAACH,KAAK,IAAI,GAAG,EAAE;IACvCI,oBAAoB,EAAEH;EACxB,CAAC,CAAC;EACF,MAAMI,IAAI,GAAGH,IAAI,CAACI,OAAO,CAACD,IAAI;EAC9B,MAAME,IAAI,GAAGL,IAAI,CAACI,OAAO,CAACC,IAAI;EAC9B,MAAMD,OAAoB,GAAG,EAAE;EAC/B,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,EAAEG,CAAC,EAAE,EAAE;IAC7B,MAAMC,GAAc,GAAG,EAAE;IACzB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,IAAI,EAAEK,CAAC,EAAE,EAAE;MAC7BD,GAAG,CAACE,IAAI,CAACJ,IAAI,CAACC,CAAC,GAAGH,IAAI,GAAGK,CAAC,CAAC,KAAK,CAAC,CAAC;IACpC;IACAJ,OAAO,CAACK,IAAI,CAACF,GAAG,CAAC;EACnB;EACA,OAAO;IAAEJ,IAAI;IAAEC;EAAQ,CAAC;AAC1B;;AAEA;AACA,OAAO,SAASM,KAAKA,CAACH,GAAW,EAAEI,GAAW,EAAER,IAAY,EAAW;EACrE,MAAMS,SAAS,GAAGL,GAAG,GAAG,CAAC,IAAII,GAAG,GAAG,CAAC;EACpC,MAAME,UAAU,GAAGN,GAAG,GAAG,CAAC,IAAII,GAAG,IAAIR,IAAI,GAAG,CAAC;EAC7C,MAAMW,YAAY,GAAGP,GAAG,IAAIJ,IAAI,GAAG,CAAC,IAAIQ,GAAG,GAAG,CAAC;EAC/C,OAAOC,SAAS,IAAIC,UAAU,IAAIC,YAAY;AAChD;AAUA,OAAO,SAASC,QAAQA,CACtBC,MAAgB,EAChBC,SAAiB,EACjBC,SAAiB,EACP;EACV,MAAMC,KAAK,GAAGH,MAAM,CAACb,IAAI,GAAGe,SAAS,GAAG,CAAC;EACzC,MAAME,IAAI,GAAGH,SAAS,GAAGE,KAAK;EAC9B,OAAO;IAAEC,IAAI;IAAEC,MAAM,EAAEH,SAAS,GAAGE,IAAI;IAAEjB,IAAI,EAAEa,MAAM,CAACb;EAAK,CAAC;AAC9D","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { geometry, isEye } from "./matrix.js";
|
|
4
|
+
function fmt(n) {
|
|
5
|
+
return Number(n.toFixed(2)).toString();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Build SVG markup for a matrix with the same styling as the component. */
|
|
9
|
+
export function qrToSVG(matrix, options) {
|
|
10
|
+
const {
|
|
11
|
+
size,
|
|
12
|
+
quietZone = 2,
|
|
13
|
+
dotStyle = 'square',
|
|
14
|
+
eyeStyle = 'square',
|
|
15
|
+
color = '#000000',
|
|
16
|
+
gradient,
|
|
17
|
+
backgroundColor = '#FFFFFF',
|
|
18
|
+
backgroundRadius = 0,
|
|
19
|
+
logoHole = 0
|
|
20
|
+
} = options;
|
|
21
|
+
const {
|
|
22
|
+
cell,
|
|
23
|
+
offset
|
|
24
|
+
} = geometry(matrix, size, quietZone);
|
|
25
|
+
const parts = [];
|
|
26
|
+
const fill = gradient ? 'url(#qrg)' : color;
|
|
27
|
+
if (gradient) {
|
|
28
|
+
const s = gradient.start ?? {
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 0
|
|
31
|
+
};
|
|
32
|
+
const e = gradient.end ?? {
|
|
33
|
+
x: 1,
|
|
34
|
+
y: 1
|
|
35
|
+
};
|
|
36
|
+
const stops = gradient.colors.map((c, i) => `<stop offset="${fmt(i / Math.max(1, gradient.colors.length - 1) * 100)}%" stop-color="${c}"/>`).join('');
|
|
37
|
+
parts.push(`<defs><linearGradient id="qrg" x1="${s.x}" y1="${s.y}" x2="${e.x}" y2="${e.y}">${stops}</linearGradient></defs>`);
|
|
38
|
+
}
|
|
39
|
+
if (backgroundColor !== 'transparent') {
|
|
40
|
+
parts.push(`<rect width="${size}" height="${size}" rx="${backgroundRadius}" fill="${backgroundColor}"/>`);
|
|
41
|
+
}
|
|
42
|
+
const holeHalf = logoHole * size / 2;
|
|
43
|
+
const centre = size / 2;
|
|
44
|
+
const dots = [];
|
|
45
|
+
for (let r = 0; r < matrix.size; r++) {
|
|
46
|
+
for (let c = 0; c < matrix.size; c++) {
|
|
47
|
+
if (!matrix.modules[r]?.[c] || isEye(r, c, matrix.size)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const x = offset + c * cell;
|
|
51
|
+
const y = offset + r * cell;
|
|
52
|
+
if (logoHole > 0 && Math.abs(x + cell / 2 - centre) < holeHalf && Math.abs(y + cell / 2 - centre) < holeHalf) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (dotStyle === 'dots') {
|
|
56
|
+
dots.push(`<circle cx="${fmt(x + cell / 2)}" cy="${fmt(y + cell / 2)}" r="${fmt(cell * 0.4)}"/>`);
|
|
57
|
+
} else if (dotStyle === 'rounded') {
|
|
58
|
+
dots.push(`<rect x="${fmt(x + cell * 0.05)}" y="${fmt(y + cell * 0.05)}" width="${fmt(cell * 0.9)}" height="${fmt(cell * 0.9)}" rx="${fmt(cell * 0.3)}"/>`);
|
|
59
|
+
} else {
|
|
60
|
+
dots.push(`<rect x="${fmt(x)}" y="${fmt(y)}" width="${fmt(cell)}" height="${fmt(cell)}"/>`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
parts.push(`<g fill="${fill}">${dots.join('')}</g>`);
|
|
65
|
+
const eyes = [[0, 0], [0, matrix.size - 7], [matrix.size - 7, 0]];
|
|
66
|
+
const eyeParts = [];
|
|
67
|
+
for (const [r, c] of eyes) {
|
|
68
|
+
const x = offset + c * cell;
|
|
69
|
+
const y = offset + r * cell;
|
|
70
|
+
const outer = cell * 7;
|
|
71
|
+
const inner = cell * 3;
|
|
72
|
+
const ix = x + cell * 2;
|
|
73
|
+
const iy = y + cell * 2;
|
|
74
|
+
if (eyeStyle === 'circle') {
|
|
75
|
+
eyeParts.push(`<circle cx="${fmt(x + outer / 2)}" cy="${fmt(y + outer / 2)}" r="${fmt(outer / 2 - cell / 2)}" fill="none" stroke="${fill}" stroke-width="${fmt(cell)}"/>`);
|
|
76
|
+
eyeParts.push(`<circle cx="${fmt(ix + inner / 2)}" cy="${fmt(iy + inner / 2)}" r="${fmt(inner / 2)}" fill="${fill}"/>`);
|
|
77
|
+
} else {
|
|
78
|
+
const rx = eyeStyle === 'rounded' ? fmt(cell * 1.6) : '0';
|
|
79
|
+
const irx = eyeStyle === 'rounded' ? fmt(cell * 0.8) : '0';
|
|
80
|
+
eyeParts.push(`<rect x="${fmt(x + cell / 2)}" y="${fmt(y + cell / 2)}" width="${fmt(outer - cell)}" height="${fmt(outer - cell)}" rx="${rx}" fill="none" stroke="${fill}" stroke-width="${fmt(cell)}"/>`);
|
|
81
|
+
eyeParts.push(`<rect x="${fmt(ix)}" y="${fmt(iy)}" width="${fmt(inner)}" height="${fmt(inner)}" rx="${irx}" fill="${fill}"/>`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
parts.push(eyeParts.join(''));
|
|
85
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">${parts.join('')}</svg>`;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["geometry","isEye","fmt","n","Number","toFixed","toString","qrToSVG","matrix","options","size","quietZone","dotStyle","eyeStyle","color","gradient","backgroundColor","backgroundRadius","logoHole","cell","offset","parts","fill","s","start","x","y","e","end","stops","colors","map","c","i","Math","max","length","join","push","holeHalf","centre","dots","r","modules","abs","eyes","eyeParts","outer","inner","ix","iy","rx","irx"],"sourceRoot":"../../src","sources":["svg.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,KAAK,QAAQ,aAAU;AAgB1C,SAASC,GAAGA,CAACC,CAAS,EAAU;EAC9B,OAAOC,MAAM,CAACD,CAAC,CAACE,OAAO,CAAC,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;AACxC;;AAEA;AACA,OAAO,SAASC,OAAOA,CAACC,MAAgB,EAAEC,OAAmB,EAAU;EACrE,MAAM;IACJC,IAAI;IACJC,SAAS,GAAG,CAAC;IACbC,QAAQ,GAAG,QAAQ;IACnBC,QAAQ,GAAG,QAAQ;IACnBC,KAAK,GAAG,SAAS;IACjBC,QAAQ;IACRC,eAAe,GAAG,SAAS;IAC3BC,gBAAgB,GAAG,CAAC;IACpBC,QAAQ,GAAG;EACb,CAAC,GAAGT,OAAO;EACX,MAAM;IAAEU,IAAI;IAAEC;EAAO,CAAC,GAAGpB,QAAQ,CAACQ,MAAM,EAAEE,IAAI,EAAEC,SAAS,CAAC;EAC1D,MAAMU,KAAe,GAAG,EAAE;EAC1B,MAAMC,IAAI,GAAGP,QAAQ,GAAG,WAAW,GAAGD,KAAK;EAE3C,IAAIC,QAAQ,EAAE;IACZ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2
|
+
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { createMatrix } from "./matrix.js";
|
|
5
|
+
/** The module grid for a value, memoised. */
|
|
6
|
+
export function useQRMatrix(value, errorCorrection = 'M') {
|
|
7
|
+
return useMemo(() => createMatrix(value, errorCorrection), [value, errorCorrection]);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=useQRMatrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","createMatrix","useQRMatrix","value","errorCorrection"],"sourceRoot":"../../src","sources":["useQRMatrix.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,YAAY,QAAQ,aAAU;AAGvC;AACA,OAAO,SAASC,WAAWA,CACzBC,KAAa,EACbC,eAAgC,GAAG,GAAG,EAC5B;EACV,OAAOJ,OAAO,CACZ,MAAMC,YAAY,CAACE,KAAK,EAAEC,eAAe,CAAC,EAC1C,CAACD,KAAK,EAAEC,eAAe,CACzB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { StyledQRHandle, StyledQRProps } from './types.js';
|
|
2
|
+
/** A QR code drawn with Skia, styled, with an optional logo and an animated reveal. */
|
|
3
|
+
export declare const StyledQR: import("react").ForwardRefExoticComponent<StyledQRProps & import("react").RefAttributes<StyledQRHandle>>;
|
|
4
|
+
//# sourceMappingURL=StyledQR.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyledQR.d.ts","sourceRoot":"","sources":["../../../src/StyledQR.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAS,CAAC;AAyH7D,uFAAuF;AACvF,eAAO,MAAM,QAAQ,0GA2JpB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { StyledQR } from './StyledQR.js';
|
|
2
|
+
export { useQRMatrix } from './useQRMatrix.js';
|
|
3
|
+
export { createMatrix, isEye, geometry } from './matrix.js';
|
|
4
|
+
export { qrToSVG, type SVGOptions } from './svg.js';
|
|
5
|
+
export type { DotStyle, ErrorCorrection, EyeStyle, QRGradient, QRLogo, QRMatrix, StyledQRHandle, StyledQRProps, } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAU,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAO,CAAC;AACjD,YAAY,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,cAAc,EACd,aAAa,GACd,MAAM,YAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ErrorCorrection, QRMatrix } from './types.js';
|
|
2
|
+
/** Encode text into a module grid. */
|
|
3
|
+
export declare function createMatrix(value: string, errorCorrection?: ErrorCorrection): QRMatrix;
|
|
4
|
+
/** True when (row, col) is inside one of the three finder patterns. */
|
|
5
|
+
export declare function isEye(row: number, col: number, size: number): boolean;
|
|
6
|
+
export interface Geometry {
|
|
7
|
+
/** Pixel size of one module. */
|
|
8
|
+
cell: number;
|
|
9
|
+
/** Offset of the first module from the edge, px. */
|
|
10
|
+
offset: number;
|
|
11
|
+
size: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function geometry(matrix: QRMatrix, pixelSize: number, quietZone: number): Geometry;
|
|
14
|
+
//# sourceMappingURL=matrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../../src/matrix.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAS,CAAC;AAEzD,sCAAsC;AACtC,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,eAAe,GAAE,eAAqB,GACrC,QAAQ,CAeV;AAED,uEAAuE;AACvE,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKrE;AAED,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,QAAQ,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,QAAQ,CAIV"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DotStyle, EyeStyle, QRGradient, QRMatrix } from './types.js';
|
|
2
|
+
export interface SVGOptions {
|
|
3
|
+
size: number;
|
|
4
|
+
quietZone?: number;
|
|
5
|
+
dotStyle?: DotStyle;
|
|
6
|
+
eyeStyle?: EyeStyle;
|
|
7
|
+
color?: string;
|
|
8
|
+
gradient?: QRGradient;
|
|
9
|
+
backgroundColor?: string;
|
|
10
|
+
backgroundRadius?: number;
|
|
11
|
+
/** A square hole in the middle, as a fraction of the size, left blank for a logo. */
|
|
12
|
+
logoHole?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Build SVG markup for a matrix with the same styling as the component. */
|
|
15
|
+
export declare function qrToSVG(matrix: QRMatrix, options: SVGOptions): string;
|
|
16
|
+
//# sourceMappingURL=svg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../../src/svg.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAS,CAAC;AAExE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD,4EAA4E;AAC5E,wBAAgB,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAuGrE"}
|