qrcodesolid 0.0.0 → 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/README.md +493 -2
- package/dist/color-parse-empty.d.ts +6 -0
- package/dist/color-parse-empty.js +7 -0
- package/dist/color-parse.d.ts +8 -0
- package/dist/color-parse.js +49 -0
- package/dist/index.d.ts +372 -0
- package/dist/index.js +2640 -0
- package/dist/paint-ChCPh-rm.d.ts +29 -0
- package/dist/payload.d.ts +53 -0
- package/dist/payload.js +93 -0
- package/dist/server.d.ts +399 -0
- package/dist/server.js +2833 -0
- package/dist/source/components/GradientDef.jsx +19 -0
- package/dist/source/components/QRCode.jsx +10 -0
- package/dist/source/components/QRCodeCanvas.jsx +72 -0
- package/dist/source/components/QRCodeSVG.jsx +57 -0
- package/dist/source/core/caption.js +77 -0
- package/dist/source/core/color-names.js +34 -0
- package/dist/source/core/color-parse-empty.js +5 -0
- package/dist/source/core/color-parse.js +41 -0
- package/dist/source/core/encode.js +120 -0
- package/dist/source/core/logo.js +90 -0
- package/dist/source/core/options.js +56 -0
- package/dist/source/core/output.js +23 -0
- package/dist/source/core/paint.js +30 -0
- package/dist/source/core/path.js +46 -0
- package/dist/source/core/qrcodegen.js +875 -0
- package/dist/source/core/scene.js +141 -0
- package/dist/source/core/stages.js +24 -0
- package/dist/source/core/warnings.js +38 -0
- package/dist/source/export/index.js +105 -0
- package/dist/source/index.js +16 -0
- package/dist/source/payload/contact.js +42 -0
- package/dist/source/payload/escape.js +3 -0
- package/dist/source/payload/index.js +3 -0
- package/dist/source/payload/message.js +19 -0
- package/dist/source/payload/place.js +40 -0
- package/dist/source/primitives/createColorScheme.js +18 -0
- package/dist/source/primitives/createPixelRatio.js +25 -0
- package/dist/source/primitives/createQRCode.js +47 -0
- package/dist/source/render/canvas.js +46 -0
- package/dist/source/render/color.js +63 -0
- package/dist/source/render/image.js +123 -0
- package/dist/source/render/svg-string.js +55 -0
- package/dist/source/shapes/bars.js +50 -0
- package/dist/source/shapes/finders.js +30 -0
- package/dist/source/shapes/frames.js +62 -0
- package/dist/source/shapes/modules.js +39 -0
- package/dist/source/shapes/types.js +8 -0
- package/llms.txt +117 -0
- package/package.json +95 -6
- package/skills/qrcodesolid/SKILL.md +101 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qrcodesolid
|
|
3
|
+
description: Render, style and export QR codes in Solid 2 apps with the qrcodesolid package. Use when code imports from 'qrcodesolid' or 'qrcodesolid/payload', or when a Solid 2 app needs a QR code with shapes, gradients, a logo, a caption, a frame, or PNG/SVG export.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# qrcodesolid
|
|
7
|
+
|
|
8
|
+
QR code components for Solid 2. Peers: `solid-js` 2 and `@solidjs/web` 2. ESM only.
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
|
|
12
|
+
1. Pass values, not accessors: `<QRCodeSVG value={url()} />`. Never `value={url}`.
|
|
13
|
+
2. Do not destructure props. Give `createQRCode` the props object: `createQRCode(props)`.
|
|
14
|
+
3. Give every code a `title`. Without it, `role="img"` has no accessible name.
|
|
15
|
+
4. Keep `margin` at 2 or more (default 4). Other QR libraries default to 0; do not copy that.
|
|
16
|
+
5. Do not pick level `L` with a logo. Leave `level` unset: an image makes it `Q`.
|
|
17
|
+
6. Wrap codes with user-supplied data in `<Errored>`: too-long data throws `QRCapacityError`.
|
|
18
|
+
7. Theme through `--qr-fg` / `--qr-bg`. A canvas redraws on a `prefers-color-scheme` change only:
|
|
19
|
+
for a class-based theme pass `repaint={theme()}`.
|
|
20
|
+
8. Decode a custom shape or frame with a real scanner before shipping it.
|
|
21
|
+
|
|
22
|
+
## Pick the API
|
|
23
|
+
|
|
24
|
+
| Need | Use |
|
|
25
|
+
| ------------------------------------- | ----------------------------------------------------------- |
|
|
26
|
+
| A code on the page | `QRCodeSVG` (or `QRCode`, default SVG) |
|
|
27
|
+
| A bitmap on the page | `QRCodeCanvas` or `<QRCode renderAs="canvas">` |
|
|
28
|
+
| A file or clipboard copy | `download`, `toPNGBlob`, `toDataURL`, `copyToClipboard` |
|
|
29
|
+
| An SVG string on the server | `toSVGString` (`resolveColors: true` for a standalone file) |
|
|
30
|
+
| Your own renderer | `createQRCode(props)` → `{ matrix, geometry, scene }` |
|
|
31
|
+
| Wi-Fi, contact, mail, SMS, geo, event | `qrcodesolid/payload` |
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Errored } from 'solid-js';
|
|
37
|
+
import { QRCodeSVG, banner, dots } from 'qrcodesolid';
|
|
38
|
+
import { wifi } from 'qrcodesolid/payload';
|
|
39
|
+
|
|
40
|
+
function WifiCode(props: { ssid: string; password: string }) {
|
|
41
|
+
return (
|
|
42
|
+
<Errored fallback={() => <p>Too much data for a QR code.</p>}>
|
|
43
|
+
<QRCodeSVG
|
|
44
|
+
value={wifi({ ssid: props.ssid, password: props.password })}
|
|
45
|
+
title={`Join ${props.ssid}`}
|
|
46
|
+
size={240}
|
|
47
|
+
modules={dots}
|
|
48
|
+
finder={{ outer: 'rounded', inner: 'dot' }}
|
|
49
|
+
fg={{ type: 'linear', rotate: 45, stops: ['#6d28d9', '#db2777'] }}
|
|
50
|
+
image={{ src: '/logo.svg', size: 0.2 }}
|
|
51
|
+
frame={banner({ text: 'Scan to join' })}
|
|
52
|
+
/>
|
|
53
|
+
</Errored>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Options
|
|
59
|
+
|
|
60
|
+
`value` (required), `size` 128, `level` 'M' ('Q' with image), `margin` 4, `fg`
|
|
61
|
+
'var(--qr-fg, #000)', `bg` 'var(--qr-bg, #fff)', `modules` square, `finder` `{ outer, inner,
|
|
62
|
+
color, innerColor }`, `image` `{ src, size 0.2, aspect 1, padding 1, radius 0, excavate true,
|
|
63
|
+
opacity 1, crossOrigin }`, `caption` `{ text, position, fontSize 2, fontFamily, fontWeight, color }`,
|
|
64
|
+
`frame` (one plugin or an array, applied from the inside out), `title`, `id`, `encoding` `{ minVersion, maxVersion, mask, boostLevel }`.
|
|
65
|
+
`QRCode` adds `renderAs`. `QRCodeCanvas` adds `onReady(canvas)`, `repaint` (any value; a new value redraws) and `imageTimeout` (ms, default 10000).
|
|
66
|
+
|
|
67
|
+
A `Paint` is a CSS colour, `{ type: 'linear', rotate?, stops }` or `{ type: 'radial', stops }`,
|
|
68
|
+
with at least two stops, checked at runtime. Gradients span the QR box (code plus margin), frame and caption paints
|
|
69
|
+
included.
|
|
70
|
+
|
|
71
|
+
## Shapes
|
|
72
|
+
|
|
73
|
+
- Modules: `square`, `dots`, `rounded`, `diamond`, `verticalBars`, `horizontalBars`.
|
|
74
|
+
- Finder outer: `'square' | 'rounded' | 'circle'`; inner: `'square' | 'rounded' | 'dot' | 'diamond'`.
|
|
75
|
+
- `defineModuleShape(({ x, y, neighbors, alignment }) => pathData)` draws one cell in scene units
|
|
76
|
+
(1 per module). Draw `alignment` cells solid.
|
|
77
|
+
- `defineLayerShape(({ matrix, include, offset }) => pathData)` draws the whole layer; skip cells
|
|
78
|
+
where `include(x, y)` is false and add `offset`.
|
|
79
|
+
- A finder part is `(x, y) => pathData` from the 7x7 pattern's top-left; outer fills `evenodd`.
|
|
80
|
+
- `getFinder(style)` returns `FinderParts` `{ outer, inner }`. `PlacedPaint` is the type of `Layer.fill`. `CrossOrigin` is `'' | 'anonymous' | 'use-credentials'`.
|
|
81
|
+
- A `FramePlugin` is `(layout) => { layout, paths, texts }`; path `paint` is a `Paint` or a
|
|
82
|
+
`PaintKey` (`'fg' | 'bg' | 'finder' | 'finderInner' | 'caption'`). Move `qr`, never resize it.
|
|
83
|
+
|
|
84
|
+
## Logo behaviour
|
|
85
|
+
|
|
86
|
+
The logo box may cover only a per-level share of modules and only data cells (and the centre
|
|
87
|
+
alignment pattern from version 7). On short values the
|
|
88
|
+
logo shrinks, or is dropped under 2 modules wide; dev builds log a warning. Raise
|
|
89
|
+
`encoding.minVersion` for a bigger logo.
|
|
90
|
+
|
|
91
|
+
## Export notes
|
|
92
|
+
|
|
93
|
+
- `toSVGString` keeps `var()`; PNG, data URLs and downloaded SVG resolve colours to the `var()`
|
|
94
|
+
fallback (`currentColor` → `#000`); pass `element` to resolve against it instead.
|
|
95
|
+
- Downloaded and data-URL SVG embed the logo as a data URL (CORS fetch); if the fetch fails they
|
|
96
|
+
keep the URL and warn. `toSVGString` keeps the URL. The fetch aborts after `imageTimeout` ms
|
|
97
|
+
(10000) and rejects over `imageMaxBytes` (2 MB).
|
|
98
|
+
- A cross-origin logo without CORS makes DOM PNG export reject with `SecurityError`. Set
|
|
99
|
+
`crossOrigin: 'anonymous'` and serve it with CORS. In a worker the logo is dropped instead.
|
|
100
|
+
|
|
101
|
+
Full reference: the package README and `llms.txt`.
|