shield-qr-styler 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ShieldQR
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,273 @@
1
+ # Shield QR Styler
2
+
3
+ Generate beautifully shaped, customizable QR codes as SVG. Framework-agnostic, works in Node.js, browsers, and edge runtimes.
4
+
5
+ ![npm](https://img.shields.io/npm/v/shield-qr-styler)
6
+ ![license](https://img.shields.io/npm/l/shield-qr-styler)
7
+ ![bundle size](https://img.shields.io/bundlephobia/minzip/shield-qr-styler)
8
+
9
+ ## Features
10
+
11
+ - **22+ Shape Variations** - Shield, heart, hexagon, circle, diamond, oval, square, rectangle, and more
12
+ - **7 Color Presets** - Cyber, stealth, royal, military, fire, ocean, monochrome
13
+ - **7 Module Styles** - Circle, rounded, diamond, square, horizontal bars, vertical bars, pond (organic blobs)
14
+ - **Gradient Support** - Linear and radial gradients with preset options
15
+ - **Effects** - Glow, inner borders, center clear (logo area), decorative fill
16
+ - **Finder Customization** - Pattern/solid mode with 4 shape styles
17
+ - **Extensible** - Register custom shapes at runtime
18
+ - **SVG Output** - Clean, scalable vector graphics
19
+ - **Isomorphic** - Works in Node.js, browsers, and edge runtimes
20
+ - **TypeScript** - Full type declarations included
21
+ - **Zero DOM Dependencies** - Pure computation, no canvas required
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install shield-qr-styler
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```javascript
32
+ import { generateShapeQR } from 'shield-qr-styler';
33
+
34
+ const svg = await generateShapeQR('https://example.com', {
35
+ shapeCategory: 'shield',
36
+ shapeVariation: 'classic',
37
+ preset: 'cyber',
38
+ });
39
+
40
+ // svg is a complete SVG string ready to use
41
+ document.getElementById('qr').innerHTML = svg;
42
+ ```
43
+
44
+ ## Shape Categories
45
+
46
+ | Category | Variations | Description |
47
+ |-------------|-------------------------------------|--------------------------------|
48
+ | `none` | default | Plain QR with no shape border |
49
+ | `square` | sharp, rounded, pill | Square with corner variations |
50
+ | `rectangle` | portrait, landscape, ticket | Rectangular with notch options |
51
+ | `circle` | perfect, squircle | Circle and iOS-icon squircle |
52
+ | `oval` | vertical, horizontal | Elliptical shapes |
53
+ | `diamond` | classic, soft | Diamond / rhombus |
54
+ | `heart` | classic, rounded | Heart shapes |
55
+ | `hexagon` | sharp, rounded | Six-sided shapes |
56
+ | `shield` | classic, badge, modern, emblem | Shield shapes (4 variations) |
57
+
58
+ ## Color Presets
59
+
60
+ ```javascript
61
+ // Use a named preset
62
+ const svg = await generateShapeQR(url, { preset: 'royal' });
63
+ ```
64
+
65
+ | Preset | Description |
66
+ |--------------|------------------------------|
67
+ | `cyber` | Neon cyan on navy |
68
+ | `stealth` | Grey on black, minimal |
69
+ | `royal` | Purple & gold, luxurious |
70
+ | `military` | Green on olive, tactical |
71
+ | `fire` | Red & orange, bold |
72
+ | `ocean` | Blue tones, professional |
73
+ | `monochrome` | Classic black on white |
74
+
75
+ ## Module Styles
76
+
77
+ ```javascript
78
+ const svg = await generateShapeQR(url, {
79
+ moduleStyle: 'pond', // organic connected blobs
80
+ moduleScale: 0.82, // dot size (0.5 - 1.0)
81
+ });
82
+ ```
83
+
84
+ Options: `circle`, `roundedSquare`, `diamond`, `square`, `barH`, `barV`, `pond`
85
+
86
+ ## Gradients
87
+
88
+ ```javascript
89
+ const svg = await generateShapeQR(url, {
90
+ gradient: {
91
+ type: 'linear',
92
+ colors: ['#00d4ff', '#7b2ff7'],
93
+ angle: 135,
94
+ stops: [0, 100],
95
+ },
96
+ });
97
+ ```
98
+
99
+ ## Effects
100
+
101
+ ```javascript
102
+ const svg = await generateShapeQR(url, {
103
+ glowEffect: true, // Outer glow
104
+ innerBorder: true, // Inner border line
105
+ centerClear: true, // Clear center for logo
106
+ centerSize: 0.22, // Logo area size
107
+ decorativeFill: true, // Scatter dots in empty areas
108
+ decorativeDensity: 0.35, // Fill density
109
+ decorativeOpacity: 0.25, // Fill opacity
110
+ });
111
+ ```
112
+
113
+ ## Custom Colors
114
+
115
+ ```javascript
116
+ const svg = await generateShapeQR(url, {
117
+ colors: {
118
+ background: '#1a0a3e',
119
+ foreground: '#c9a0ff',
120
+ outline: '#ffd700',
121
+ finderOuter: '#ffd700',
122
+ finderInner: '#c9a0ff',
123
+ outlineWidth: 3,
124
+ },
125
+ });
126
+ ```
127
+
128
+ ## Finder Pattern Customization
129
+
130
+ ```javascript
131
+ const svg = await generateShapeQR(url, {
132
+ finderPattern: 'solid', // 'pattern' or 'solid'
133
+ finderOuterStyle: 'rounded', // 'rounded', 'square', 'circle', 'diamond'
134
+ finderInnerStyle: 'circle',
135
+ finderScale: 1.0,
136
+ });
137
+ ```
138
+
139
+ ## API Reference
140
+
141
+ ### Core Functions
142
+
143
+ ```javascript
144
+ import {
145
+ generateShapeQR, // (data, options?) => Promise<string>
146
+ generateShapeQRBuffer, // (data, options?) => Promise<Buffer | Uint8Array>
147
+ generateShapeQRDataURI, // (data, options?) => Promise<string>
148
+ } from 'shield-qr-styler';
149
+ ```
150
+
151
+ ### Library Access
152
+
153
+ ```javascript
154
+ import {
155
+ getShapeLibrary, // () => full shape library object
156
+ getShapeCategories, // () => string[]
157
+ getShapeVariations, // (category) => string[]
158
+ getColorPresets, // () => string[]
159
+ getPresetColors, // (name) => ColorPreset | null
160
+ registerShape, // (key, definition, merge?) => void
161
+ resolveShape, // (design) => { category, variation, shape }
162
+ resolveColors, // (design) => { background, foreground, ... }
163
+ } from 'shield-qr-styler';
164
+ ```
165
+
166
+ ### Constants
167
+
168
+ ```javascript
169
+ import {
170
+ SHAPE_LIBRARY, // Full shape definitions
171
+ COLOR_PRESETS, // Color preset definitions
172
+ MODULE_STYLES, // Module style metadata
173
+ FINDER_PATTERNS, // Finder pattern modes
174
+ FINDER_STYLES, // Finder shape styles
175
+ GRADIENT_PRESETS, // Gradient preset definitions
176
+ DEFAULT_OPTIONS, // Default generation options
177
+ DEFAULT_DESIGN, // Default UI design config
178
+ } from 'shield-qr-styler';
179
+ ```
180
+
181
+ ### Custom Shapes
182
+
183
+ ```javascript
184
+ import { registerShape, generateShapeQR } from 'shield-qr-styler';
185
+
186
+ registerShape('star', {
187
+ label: 'Star',
188
+ icon: '⭐',
189
+ description: 'Star shapes',
190
+ variations: {
191
+ fivePoint: {
192
+ label: '5 Point',
193
+ viewBox: '0 0 300 300',
194
+ width: 300, height: 300,
195
+ path: 'M 150 10 L 190 110 ...',
196
+ qrArea: { x: 65, y: 70, size: 170 },
197
+ },
198
+ },
199
+ });
200
+
201
+ const svg = await generateShapeQR(url, {
202
+ shapeCategory: 'star',
203
+ shapeVariation: 'fivePoint',
204
+ });
205
+ ```
206
+
207
+ ## Framework Examples
208
+
209
+ ### React
210
+
211
+ ```jsx
212
+ import { useState, useEffect } from 'react';
213
+ import { generateShapeQR } from 'shield-qr-styler';
214
+
215
+ function QRCode({ url, options }) {
216
+ const [svg, setSvg] = useState('');
217
+ useEffect(() => {
218
+ generateShapeQR(url, options).then(setSvg);
219
+ }, [url, options]);
220
+ return <div dangerouslySetInnerHTML={{ __html: svg }} />;
221
+ }
222
+ ```
223
+
224
+ ### Next.js Server Component
225
+
226
+ ```jsx
227
+ import { generateShapeQR } from 'shield-qr-styler';
228
+
229
+ export default async function QRPage() {
230
+ const svg = await generateShapeQR('https://example.com', {
231
+ shapeCategory: 'shield',
232
+ preset: 'royal',
233
+ });
234
+ return <div dangerouslySetInnerHTML={{ __html: svg }} />;
235
+ }
236
+ ```
237
+
238
+ ### Express API
239
+
240
+ ```javascript
241
+ import express from 'express';
242
+ import { generateShapeQR } from 'shield-qr-styler';
243
+
244
+ const app = express();
245
+
246
+ app.get('/api/qr', async (req, res) => {
247
+ const svg = await generateShapeQR(req.query.url, {
248
+ shapeCategory: req.query.shape || 'shield',
249
+ preset: req.query.preset || 'cyber',
250
+ });
251
+ res.setHeader('Content-Type', 'image/svg+xml');
252
+ res.send(svg);
253
+ });
254
+ ```
255
+
256
+ ## TypeScript
257
+
258
+ Full type declarations are included:
259
+
260
+ ```typescript
261
+ import type {
262
+ GenerateOptions,
263
+ DesignConfig,
264
+ ShapeCategory,
265
+ ShapeVariation,
266
+ ColorPreset,
267
+ GradientConfig,
268
+ } from 'shield-qr-styler';
269
+ ```
270
+
271
+ ## License
272
+
273
+ MIT