@monowind/qr-code 0.2.9

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) 2026 Benoît Rouleau
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,81 @@
1
+ # @monowind/qr-code
2
+
3
+ Scannable QR codes on the [monowind](https://github.com/benface/monowind)
4
+ grid: the `<mono-qr>` element.
5
+
6
+ ```html
7
+ <mono-qr class="mx-auto px-4 py-2">https://play.monowind.benface.com</mono-qr>
8
+ ```
9
+
10
+ The element's text is the value. The code renders as block glyphs on
11
+ the grid, packed to the font's real cell proportions — half blocks
12
+ where a cell is twice as tall as wide, so a version-1 code is 21
13
+ columns by 11 rows — while the light DOM keeps the value for screen
14
+ readers. A drag over the code selects its characters (a transparent
15
+ transcript in the element's shadow), and a copy pastes into a
16
+ terminal as a working code.
17
+
18
+ The rows are the bare symbol: give it the light margin readers need
19
+ (the _quiet zone_, four modules in the QR standard) as padding —
20
+ `px-4 py-2` at the usual cell, `px-2 py-1` where most phones still
21
+ cope — or blank surroundings. Utilities style it: `text-*` sets the
22
+ modules' color, `bg-*` the background, padding included;
23
+ `bg-white text-black` is a guaranteed-normal code on any theme, and
24
+ it behaves like a replaced element (`mx-auto` centers it).
25
+
26
+ ## Setup, by integration
27
+
28
+ **Your own Tailwind v4 build, or `@monowind/vite`** — import the
29
+ element and the companion styles next to monowind's:
30
+
31
+ ```ts
32
+ import { defineMonoWind } from "monowind";
33
+ import "@monowind/qr-code";
34
+
35
+ defineMonoWind(); // `@monowind/vite` does this for you
36
+ ```
37
+
38
+ ```css
39
+ @import "tailwindcss";
40
+ @import "monowind";
41
+ @import "@monowind/qr-code";
42
+ ```
43
+
44
+ **CDN, no build** — one script after monowind's:
45
+
46
+ ```html
47
+ <script src="https://unpkg.com/monowind/dist/cdn.js"></script>
48
+ <script src="https://unpkg.com/@monowind/qr-code/dist/cdn.js"></script>
49
+ ```
50
+
51
+ ## Attributes
52
+
53
+ - `level` — error correction, `L` `M` `Q` `H` (7%, 15%, 25%, 30% of
54
+ the code may be damaged), default `M`. The code is the smallest
55
+ version that holds the value; spare room raises the level for free.
56
+ - `aspect` — the cell's height over its width, default `auto`
57
+ (measured, snapped to the nearest packing): `2` packs two module
58
+ rows per cell with half blocks, `4` the same two cells wide, `1`
59
+ one module per cell, `0.5` one module two rows tall.
60
+ - `scale` — an integer from 1 to 16 (default `1`); the symbol grows
61
+ uniformly (scale the padding with it).
62
+
63
+ A glyph set of your own restyles the modules: `qrFull`, `qrUpper`,
64
+ and `qrLower` on its `solid` table (`registerBorderGlyphs` in
65
+ monowind, then `--mw-border-glyphs` on the element or a theme). A set
66
+ naming `qrFull` alone has no half blocks, so each module is two cells
67
+ wide — `##` for an ASCII-only code. The built-in sets all draw the
68
+ default blocks.
69
+
70
+ **Playground** — [play.monowind.benface.com](https://play.monowind.benface.com)
71
+ has all of this wired: type `<mono-qr>` with any value.
72
+
73
+ ## API
74
+
75
+ - `encode(value, level)`, `scaleUp`, `pack`, `renderQr` — the pure
76
+ pipeline, for rendering codes outside the element.
77
+ - `snapAspect(ratio)`, `resolveGlyphs(set)`, `DEFAULT_GLYPHS`.
78
+ - `defineMonoQr()`, `MonoQrElement`.
79
+
80
+ The encoder is the [`qr`](https://www.npmjs.com/package/qr) package,
81
+ used under its MIT license.
package/dist/cdn.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * CDN entry — a classic script loaded NEXT TO monowind's own cdn.js:
3
+ *
4
+ * <script src=".../monowind/dist/cdn.js"></script>
5
+ * <script src=".../@monowind/qr-code/dist/cdn.js"></script>
6
+ *
7
+ * Registers <mono-qr>, injects the companion styles, and merges its
8
+ * version into the shared `monowind` global.
9
+ */
10
+ import "./index.ts";
11
+ //# sourceMappingURL=cdn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,YAAY,CAAC"}
package/dist/cdn.js ADDED
@@ -0,0 +1,10 @@
1
+ (function(e){var t=1024,n=t*4,r=(()=>{let e=[];for(let t=1;t<=40;t++){let n=(16*t+128)*t+64;if(t>=2){let e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}e.push(n>>>3)}return e})(),i=[`low`,`medium`,`quartile`,`high`],a={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},o={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},s={low:1,medium:0,quartile:3,high:2},c=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;function l(e){if(e=x(e),e===1)return[];let t=21+4*(e-1)-7,n=Math.ceil((t-6)/28),r=Math.floor((t-6)/n);r%2?r+=1:(t-6)%n*2>=n&&(r+=2);let i=[6];for(let e=1;e<n;e++)i.push(t-(n-e)*r);return i.push(t),i}function u(e,t){let n=s[e]<<3|t,r=n;for(let e=0;e<10;e++)r=r<<1^(r>>9)*1335;return(n<<10|r)^21522}function d(e){let t=e;for(let e=0;e<12;e++)t=t<<1^(t>>11)*7973;return e<<12|t}var f={numeric:1,alphanumeric:2,byte:4},p={numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16]},m=(()=>{let e=new Uint8Array(510),t=new Uint8Array(256);for(let n=0,r=1;n<255;n++)e[n]=e[n+255]=r,t[r]=n,r<<=1,r&256&&(r^=285);return{exp:e,log:t}})();function h(e){let{exp:t,log:n}=m,r=new Uint8Array(e);r[e-1]=1;for(let i=0,a=1;i<e;i++){for(let i=0;i<e;i++){let o=r[i];r[i]=(o?t[n[o]+n[a]]:0)^(i+1<e?r[i+1]:0)}a=t[n[a]+1]}return r}var g=[];function _(e){let t=g[e];if(t!==void 0)return t;let n=h(e),{exp:r,log:i}=m,a=new Uint8Array(256*e);for(let t=1;t<256;t++){let o=i[t],s=t*e;for(let t=0;t<e;t++){let e=n[t];e&&(a[s+t]=r[i[e]+o])}}return g[e]={gen:n,mul:a}}function v(e,t,n){let{exp:r,log:i}=m,a=t.length,o=new Uint8Array(a);if(n!==void 0){let t=a-1;for(let r=0;r<e.length;r++){let i=(e[r]^o[0])*a;for(let e=0;e<t;e++)o[e]=o[e+1]^n[i+e];o[t]=n[i+t]}return o}for(let n=0;n<e.length;n++){let s=e[n]^o[0];if(o.copyWithin(0,1),o[a-1]=0,s)for(let e=0;e<a;e++)t[e]&&(o[e]^=r[i[t[e]]+i[s]])}return o}function y(e,t){let n=r[e-1],i=a[t][e-1],s=o[t][e-1],c=Math.floor(n/s)-i;return{words:i,numBlocks:s,shortBlocks:s-n%s,blockLen:c,capacity:(n-i*s)*8}}var b=e=>{throw Error(e)};function x(e){if(typeof e!=`number`)throw TypeError(`"ver" expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`"ver" expected safe integer, got ${e}`);if(e<1||e>40)throw RangeError(`Invalid version=${e}. Expected number [1..40]`);return e}function S(e){let t=`numeric`;for(let n=0;n<e.length;n++){let r=C[e.charCodeAt(n)];if(!(r>=0))return`byte`;r>9&&(t=`alphanumeric`)}return t}var C=(()=>{let e=new Int8Array(128).fill(-1);for(let t=0;t<45;t++)e[c.charCodeAt(t)]=t;return e})();function w(e,t,n,r,i){let a=y(e,t),o=p[r][Math.floor((e+7)/17)],s=r===`byte`?i.length:n.length;s>=1<<o&&b(`Capacity overflow`);let c=new Uint8Array(a.capacity>>>3),l=0,u=0,d=0,m=(e,t)=>{for(l=l<<t|e,u+=t;u>=8;)c[d++]=l>>>(u-=8)&255};if(m(f[r],4),m(s,o),r===`numeric`)for(let e=0;e<s;e+=3){let t=Math.min(3,s-e);m(Number(n.slice(e,e+t)),[0,4,7,10][t])}else if(r===`alphanumeric`){for(let e=0;e+1<s;e+=2)m(C[n.charCodeAt(e)]*45+C[n.charCodeAt(e+1)],11);s&1&&m(C[n.charCodeAt(s-1)],6)}else for(let e=0;e<i.length;e++)m(i[e],8);let h=d*8+u;h>a.capacity&&b(`Capacity overflow`),u&&(c[d]=l<<8-u&255),h+=Math.min(4,a.capacity-h),h&7&&(h+=8-(h&7));for(let e=h>>>3,t=0;e<c.length;e++,t^=1)c[e]=t?17:236;let{words:g,numBlocks:x,shortBlocks:S,blockLen:w}=a,T=_(g),E=[],D=[];for(let e=0,t=0;e<x;e++){let n=w+(e<S?0:1);E.push(c.subarray(t,t+n)),D.push(v(E[e],T.gen,T.mul)),t+=n}let O=new Uint8Array(c.length+g*x),k=0;for(let e=0;e<=w;e++)for(let t of E)e<t.length&&(O[k++]=t[e]);for(let e=0;e<g;e++)for(let t of D)O[k++]=t[e];return O}function T(e,t){let n=e%2,r=t%2,i=e%3,a=t%3*i%3,o=n&r,s=0;return n===r&&(s|=1),r===0&&(s|=2),i===0&&(s|=4),(e+t)%3==0&&(s|=8),(Math.floor(t/2)+Math.floor(e/3))%2==0&&(s|=16),o+a===0&&(s|=32),(o+a)%2==0&&(s|=64),((n^r)+a)%2==0&&(s|=128),s}var E=(()=>{let e=new Uint8Array(65536);for(let t=1;t<e.length;t++)e[t]=e[t>>>1]+(t&1);return e})(),D=e=>E[e&65535]+E[e>>>16],O=new Uint32Array(32);function k(e){let t=[1431655765,858993459,252645135,16711935,65535];for(let n=0;n<5;n++){let r=t[n]>>>0,i=1<<n;for(let t=0;t<32;t+=i<<1)for(let n=0;n<i;n++){let a=e[t+n]>>>0,o=e[t+n+i]>>>0,s=(a>>>i^o)&r;e[t+n]=(a^s<<i)>>>0,e[t+n+i]=(o^s)>>>0}}}var A=e=>{let t=e+31>>>5;return{size:e,words:t,v:new Uint32Array(t*e)}},j=(e,t,n)=>e.v[n*e.words+(t>>>5)]>>>(t&31)&1,M=(e,t,n,r)=>{let i=n*e.words+(t>>>5),a=1<<(t&31);e.v[i]=r?e.v[i]|a:e.v[i]&~a};function N(e,t){let{size:n,words:r,v:i}=e,a=O;for(let e=0;e<n;e+=32)for(let o=0;o<r;o++){let s=Math.min(32,n-e);for(let t=0;t<s;t++)a[t]=i[(e+t)*r+o];a.fill(0,s),k(a);for(let r=0,i=o*32;r<32&&i<n;r++,i++)t.v[i*t.words+(e>>>5)]=a[r]}}function P(e){let{size:t,words:n,v:r}=e,i=t&31?(1<<(t&31))-1>>>0:4294967295,a=0;for(let e=0;e<n;e++){let o=e===n-1?i:4294967295,s=r[3*n+e],c=4294967295,l=r[e]^r[n+e],u=r[n+e]^r[2*n+e],d=r[2*n+e]^s;for(let i=0,f=4*n+e;i<=t-5;i++,f+=n){let e=r[f],t=s^e,n=~(l|u|d|t)&o;n&&(a+=D(n>>>0)+2*D((n&c)>>>0)),c=l,l=u,u=d,d=t,s=e}}return a}function F(e){let{size:t,words:n,v:r}=e,i=t&31?(1<<(t&31))-1>>>0:4294967295,a=0;for(let e=0;e<n;e++){let o=e===n-1?i:4294967295;for(let i=0;i<=t-11;i++){let t=i*n+e,s=r[t],c=r[t+=n],l=r[t+=n],u=r[t+=n],d=r[t+=n],f=r[t+=n],p=r[t+=n],m=r[t+=n],h=r[t+=n],g=r[t+=n],_=r[t+n],v=o&s&~c&l&u&d&~f&p&~(m|h|g|_),y=o&~(s|c|l|u)&d&~f&p&m&h&~g&_;a+=D(v>>>0)+D(y>>>0)}}return a}function ee(e,t,n=1/0){let{size:r,words:i,v:a}=e,o=P(e)+P(t);if(o>=n)return o;let s=(1<<r-32*(i-1)-1)-1>>>0,c=0,l=0;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let n=a[e*i+t];if(l+=D(n>>>0),e===r-1)continue;let o=a[(e+1)*i+t],u=t+1<i?a[e*i+t+1]:0,d=t+1<i?a[(e+1)*i+t+1]:0,f=~(n^o),p=~(n^(n>>>1|u<<31)),m=~(o^(o>>>1|d<<31)),h=f&p&m;t===i-1&&(h&=s),c+=D(h>>>0)}let u=r*r,d=Math.ceil(Math.max(0,Math.abs(l*100-u*50)-u*5)/(u*5)),f=o+3*c+10*d;return f>=n?f:f+40*(F(e)+F(t))}function te(e,t,n,r){let i=e.size,a=u(n,r);for(let t=0;t<15;t++){let n=a>>t&1;t<6?M(e,8,t,n):t<8?M(e,8,t+1,n):t===8?M(e,7,8,n):M(e,14-t,8,n),t<8?M(e,i-1-t,8,n):M(e,8,i-15+t,n)}if(M(e,8,i-8,1),t>=7){let n=d(t);for(let t=0;t<18;t++){let r=n>>t&1,a=i-11+t%3,o=t/3|0;M(e,a,o,r),M(e,o,a,r)}}}var I;function ne(e){let t=21+4*(e-1),n=A(t),r=new Uint8Array(t*t),i=(e,i,a)=>{M(n,e,i,a),r[i*t+e]=1};for(let[e,n]of[[0,0],[t-7,0],[0,t-7]])for(let r=-1;r<8;r++)for(let a=-1;a<8;a++){let o=e+a,s=n+r;o<0||s<0||o>=t||s>=t||i(o,s,+(a>=0&&a<7&&r>=0&&r<7&&(a===0||a===6||r===0||r===6||a>1&&a<5&&r>1&&r<5)))}let a=l(e);for(let e of a)for(let n of a)if(!r[e*t+n])for(let t=-2;t<=2;t++)for(let r=-2;r<=2;r++){let a=Math.max(Math.abs(r),Math.abs(t))!==1;i(n+r,e+t,+!!a)}for(let e=0;e<t;e++)r[6*t+e]||i(e,6,+(e%2==0)),r[e*t+6]||i(6,e,+(e%2==0));for(let e=0;e<9;e++)e!==6&&(i(8,e,0),i(e,8,0)),e<8&&(i(t-1-e,8,0),i(8,t-1-e,0));if(e>=7)for(let e=0;e<18;e++){let n=t-11+e%3,r=e/3|0;i(n,r,0),i(r,n,0)}let o=[];for(let e=0;e<8;e++)o.push(A(t));let s=new Uint16Array(t*t),c=0;for(let e=t-1,i=-1,a=t-1;e>0;e-=2,i=-i)for(e===6&&(e=5);;a+=i){for(let i=0;i<2;i++){let l=e-i;if(r[a*t+l])continue;let u=a*n.words+(l>>>5);s[c++]=u<<5|l&31;for(let e=0,t=T(l,a);t;e++,t>>=1)t&1&&(o[e].v[u]|=1<<(l&31))}if(a+i<0||a+i>=t)break}let u=o.map(e=>{let n=A(t);return N(e,n),n.v});return{ver:e,tpl:n.v,pos:s.slice(0,c),planes:o.map(e=>e.v),planesT:u,work:[A(t),A(t),A(t),A(t)]}}function re(e,t,n,r,i=!1){(I===void 0||I.ver!==e)&&(I=ne(e));let{tpl:a,pos:o,planes:s,planesT:c,work:l}=I,[u,d,f,p]=l;u.v.set(a);let m=Math.min(8*n.length,o.length);for(let e=0;e<m;e++)if(n[e>>>3]&128>>>(e&7)){let t=o[e];u.v[t>>>5]|=1<<(t&31)}let h=r;if(h===void 0){N(u,d);let e=1/0;for(let t=0;t<8;t++){let n=s[t],r=c[t];for(let e=0;e<f.v.length;e++)f.v[e]=u.v[e]^n[e],p.v[e]=d.v[e]^r[e];let i=ee(f,p,e);i<e&&(e=i,h=t)}}let g=s[h];for(let e=0;e<u.v.length;e++)u.v[e]^=g[e];return i||te(u,e,t,h),u}var L=(e,t)=>{if(typeof e!=`number`)throw TypeError(`"${t}" expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`"${t}" expected safe integer, got ${e}`);return e},R=(e,t)=>{if(typeof e!=`string`)throw TypeError(`"${t}" expected string, got type=${typeof e}`);return e};function ie(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<128)t++;else if(r<2048)t+=2;else if(r<55296||r>57343)t+=3;else if(r<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=4,n++):t+=3}else t+=3}return t}function ae(e,t){let n=p.byte[Math.floor((e+7)/17)];return Math.min((1<<n)-1,Math.floor((y(e,t).capacity-4-n)/8))}function oe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var z=(e,t,n)=>e.map[t]>=0&&e.map[n]>=0&&j(e.m,e.map[t],e.map[n])===1,B=[10,27],V=String.fromCharCode(B[0]);function se(e){let t=e.W,n=Array(t);for(let r=0;r<t;r++){let i=Array(t);for(let n=0;n<t;n++)i[n]=z(e,n,r);n[r]=i}return n}function ce(e){let t=e.W,n=``;for(let r=0;r<t;r+=2){for(let i=0;i<t;i++){let a=z(e,i,r),o=r+1>=t||z(e,i,r+1);n+=!a&&!o?`█`:!a&&o?`▀`:a&&!o?`▄`:` `}n+=V}return n}function le(e){let t=e.W,n=String.fromCharCode(B[1]),r=n+`[0m`,i=``;for(let a=0;a<t;a++){for(let o=0;o<t;o++)i+=z(e,o,a)?`${n}[40m ${r}`:`${n}[1;47m ${r}`;i+=V}return i}function ue(e,t){let n=e.W,r=`<svg viewBox="0 0 ${n} ${n}" xmlns="http://www.w3.org/2000/svg">`,i=``,a;for(let o=0;o<n;o++)for(let s=0;s<n;s++){if(!z(e,s,o))continue;if(!t){r+=`<rect x="${s}" y="${o}" width="1" height="1" />`;continue}let n=`M${s} ${o}`;if(a){let e=`m${s-a.x} ${o-a.y}`;e.length<=n.length&&(n=e)}i+=`${n}h1v1${s<10?`H${s}`:`h-1`}Z`,a={x:s,y:o}}return t&&(r+=`<path d="${i}"/>`),r+`</svg>`}function H(e){let t=e.W,n=t*t,r=Math.floor(n/126),i=n%126,a=new Uint8Array(408+r*128+2+i+4),o=0,s=e=>{a[o++]=e&255,a[o++]=e>>>8};for(let e of[71,73,70,56,55,97])a[o++]=e;s(t),s(t),a[o++]=246,o+=2,a[o++]=255,a[o++]=255,a[o++]=255,o+=381,a[o++]=44,o+=4,s(t),s(t),a[o++]=0,a[o++]=7;let{m:c,map:l}=e,u=new Uint8Array(t),d=-2;for(let e=0,r=0;e<t;e++){let i=l[e];if(i!==d&&(d=i,u.fill(0),i>=0))for(let e=0;e<t;e++)l[e]>=0&&(u[e]=j(c,l[e],i));for(let e=0;e<t;){if(r%126==0){let e=n-r;a[o++]=(e<126?e:126)+1,a[o++]=128}let i=Math.min(126-r%126,t-e);a.set(u.subarray(e,e+i),o),o+=i,e+=i,r+=i}}return i===0&&(a[o++]=1,a[o++]=128),a[o++]=1,a[o++]=129,a[o++]=0,a[o++]=59,a}function de(e){let t=e,n;if(typeof t.toBase64==`function`)n=t.toBase64();else{let e=``;for(let n=0;n<t.length;n+=8192)e+=String.fromCharCode(...t.subarray(n,n+8192));n=btoa(e)}return`data:image/gif;base64,`+n}function fe(e,r=`raw`,a={}){if(R(e,`text`),R(r,`output`),typeof a!=`object`||!a||Array.isArray(a))throw TypeError(`"opts" expected object, got type=${typeof a}`);let o=a.version;o!==void 0&&(o=x(o));let s=a.ecc===void 0?`medium`:a.ecc;i.includes(s)||b(`invalid ecc=${s}`);let l=a.encoding===void 0?S(e):a.encoding;if(p[l]||b(`invalid encoding=${l}`),l!==`byte`){let t=l===`numeric`?c.slice(0,10):c;for(let n of e)t.includes(n)||b(`Unknown letter: "${n}". Allowed: ${t}`)}a.mask!==void 0&&(L(a.mask,`opts.mask`)<0||a.mask>7)&&b(`invalid mask=${a.mask}`);let u=a.textEncoder;if(l===`byte`&&u===void 0){let t=ae(o===void 0?40:o,s);(e.length>t||ie(e)>t)&&b(`Capacity overflow`)}let d=l===`byte`?(u===void 0?e=>new TextEncoder().encode(e):u)(e):void 0;if(d!==void 0&&!oe(d))throw TypeError(`"opts.textEncoder" expected Uint8Array, got type=${typeof d}`);let f=l===`byte`?d.length:e.length,m=l===`numeric`?Math.floor(f/3)*10+[0,4,7][f%3]:l===`alphanumeric`?Math.floor(f/2)*11+f%2*6:f*8;if(o===void 0){for(o=1;o<=40;o++){let e=p[l][Math.floor((o+7)/17)];if(f<1<<e&&4+e+m<=y(o,s).capacity)break}o>40&&b(`Capacity overflow`)}else{let e=p[l][Math.floor((o+7)/17)];(f>=1<<e||4+e+m>y(o,s).capacity)&&b(`Capacity overflow`)}let h=w(o,s,e,l,d),g=re(o,s,h,a.mask),_=a.border===void 0?2:L(a.border,`opts.border`);if(_<=0)throw RangeError(`invalid border=${_}`);let v=a.scale===void 0?1:L(a.scale,`opts.scale`);if(v<=0||v>1024)throw RangeError(`invalid scale factor: ${v}`);let C=(g.size+2*_)*v,T=r===`ascii`||r===`gif`||r===`data-url`?n:t;if(C>T)throw RangeError(`invalid opts: output is ${C}x${C} (max ${T}), reduce border/scale`);let E=new Int32Array(C);for(let e=0;e<C;e++){let t=Math.floor(e/v)-_;E[e]=t>=0&&t<g.size?t:-1}let D={m:g,W:C,map:E};return r===`raw`?se(D):r===`ascii`?ce(D):r===`term`?le(D):r===`svg`?ue(D,a.optimize===void 0||a.optimize):r===`gif`?H(D):r===`data-url`?de(H(D)):b(`Unknown output: ${r}`)}var U={full:`█`,upper:`▀`,lower:`▄`},pe={L:`low`,M:`medium`,Q:`quartile`,H:`high`},W=[`L`,`M`,`Q`,`H`];function G(e,t,n){try{return fe(e,`raw`,{ecc:pe[t],border:1,version:n}).slice(1,-1).map(e=>e.slice(1,-1))}catch(e){if(e instanceof Error&&e.message===`Capacity overflow`)return null;throw e}}function K(e,t){let n=G(e,t);if(!n)return null;let r=(n.length-17)/4,i=t;for(let a of W.slice(W.indexOf(t)+1).reverse()){let t=G(e,a,r);if(t){n=t,i=a;break}}return{modules:n,version:r,level:i}}function q(e,t){if(t===1)return e;let n=[];for(let r of e){let e=r.flatMap(e=>Array.from({length:t},()=>e));for(let r=0;r<t;r++)n.push(e)}return n}function J(e){return e>=1.5?2*Math.max(1,Math.round(e/2)):e<=.75?1/Math.max(2,Math.round(1/e)):1}function me(e){let t=e?.solid,n=t?.qrFull??U.full;return t?.qrUpper&&t.qrLower?{full:n,upper:t.qrUpper,lower:t.qrLower}:!t?.qrFull&&!t?.qrUpper&&!t?.qrLower?{...U}:{full:n}}function Y(e,t,n){let r=J(t),i=[];if(r>=2&&n.upper&&n.lower){let t=r/2;for(let r=0;r<e.length;r+=2){let a=e[r],o=e[r+1],s=``;for(let e=0;e<a.length;e++){let r=a[e],i=o?.[e]??!1,c=r&&i?n.full:r?n.upper:i?n.lower:` `;s+=c.repeat(t)}i.push(s)}return i}let a=r>=1?r:1,o=r<1?Math.round(1/r):1,s=n.full.repeat(a),c=` `.repeat(a);for(let t of e){let e=t.map(e=>e?s:c).join(``);for(let t=0;t<o;t++)i.push(e)}return i}function he(e,t){let n=K(e,t.level);return n?Y(q(n.modules,t.scale),t.aspect,t.glyphs):null}var ge=typeof HTMLElement>`u`?class{}:HTMLElement,_e=`<style>
2
+ :host { display: block; }
3
+ #mirror { margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; color: transparent; }
4
+ /* The engine paints a selection on its grid (specs/wide-characters.md);
5
+ * the transcript's own highlight stays invisible, like the light DOM's. */
6
+ #mirror::selection { color: transparent; text-shadow: none; background: transparent; }
7
+ .alt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; user-select: none; -webkit-user-select: none; }
8
+ </style><pre id="mirror" aria-hidden="true"></pre><span class="alt"><slot></slot></span>`,ve=class extends ge{#e=null;constructor(){super();let e=this.attachShadow({mode:`open`});e.innerHTML=_e,this.#e=e.getElementById(`mirror`)}syncMirror(e){let t=e.join(`
9
+ `);this.#e&&this.#e.textContent!==t&&(this.#e.textContent=t)}},X=new WeakSet,Z=new WeakSet,Q=new WeakMap,ye=16;function be(e){let t=xe(e);return e.syncMirror?.(t),{lines:t}}function xe(t){let n=(t.textContent??``).replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,``);if(t.children.length>0&&!X.has(t)&&(X.add(t),console.warn(`[monowind] <mono-qr> takes text only; element children are ignored.`,t)),!n)return[];let r=Se(t),i=Q.get(t);i||Q.set(t,i={encodeKey:``,encoded:null,rowsKey:``,rows:[]});let a=`${r}\0${n}`;if(i.encodeKey!==a&&(i.encodeKey=a,i.encoded=K(n,r),i.rowsKey=``),!i.encoded)return Z.has(t)||(Z.add(t),console.warn(`[monowind] <mono-qr>: the value does not fit a QR code at level ${r}.`,t)),[];let o=typeof getComputedStyle==`function`?getComputedStyle(t):null,s=Ce(t),c=we(t,o),l=me((0,e.glyphSetFor)(o?.getPropertyValue(`--mw-border-glyphs`))),u=`${s}\0${c}\0${l.full}\0${l.upper??``}\0${l.lower??``}`;return i.rowsKey!==u&&(i.rowsKey=u,i.rows=Y(q(i.encoded.modules,s),c,l)),i.rows}function Se(e){let t=(e.getAttribute(`level`)??`M`).toUpperCase();return W.includes(t)?t:`M`}function Ce(e){let t=Number(e.getAttribute(`scale`)||NaN);return Number.isInteger(t)&&t>=1?Math.min(t,ye):1}function we(e,t){let n=Number(e.getAttribute(`aspect`));if(Number.isFinite(n)&&n>0)return J(n);let r=parseFloat(t?.getPropertyValue(`--mw-cw`)??``),i=parseFloat(t?.getPropertyValue(`--mw-ch`)??``);return r>0&&i>0?J(i/r):2}function Te(){typeof customElements>`u`||customElements.get(`mono-qr`)||(customElements.define(`mono-qr`,ve),(0,e.registerLeafRenderer)({tag:`mono-qr`,observedAttributes:[`level`,`aspect`,`scale`],render:be,selectionTarget:e=>e.shadowRoot?.getElementById(`mirror`)??null}))}Te();var Ee=`@layer base{mono-qr{display:block}}`,$=document.createElement(`style`);$.setAttribute(`data-monowind-qr`,``),$.textContent=Ee,document.head.appendChild($);var De=globalThis.monowind;Object.assign(globalThis,{monowind:{...De,qr:{...De?.qr,encode:K,renderQr:he,version:`0.2.9`}}})})(monowind);
10
+ //# sourceMappingURL=cdn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn.js","names":[],"sources":["../../../node_modules/.pnpm/qr@0.7.0/node_modules/qr/index.js","../src/render.ts","../src/index.ts","../src/styles.css?inline","../src/cdn.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023 Paul Miller (paulmillr.com)\n * SPDX-License-Identifier: MIT OR Apache-2.0\n */\n/**\n * QR code generator (encoder). Self-contained (no imports); the decoder and\n * its shared machinery (Bitmap, tables, GF/RS) live in `decode.ts`.\n *\n * What was deliberately dropped vs the full encoder: the tri-state Bitmap\n * drawing DSL, the shared decoder utilities, and verbose validation messages.\n * What was deliberately kept: word-parallel mask penalty scoring over packed\n * bit rows — it is the one optimization whose absence would make\n * large-payload encodes ~5-10x slower while costing only a few hundred\n * bytes — plus a single-slot per-version cache of the symbol template,\n * zigzag order and mask planes (see SymCache).\n * @module\n */\nconst MAX_OUTPUT_SIZE = 1024;\nconst MAX_COMPACT_OUTPUT_SIZE = MAX_OUTPUT_SIZE * 4;\n/**\n * ISO/IEC 18004:2024 Table 1: total codewords by version (shared with the\n * decoder). Computed as data modules / 8: symbol area minus function\n * patterns (finders+separators+format 191+timing, alignment grid overlaps\n * removed) minus version info for ver >= 7.\n */\nconst BYTES = /* @__PURE__ */ (() => {\n const res = [];\n for (let ver = 1; ver <= 40; ver++) {\n let bits = (16 * ver + 128) * ver + 64;\n if (ver >= 2) {\n const align = Math.floor(ver / 7) + 2;\n bits -= (25 * align - 10) * align - 55;\n if (ver >= 7)\n bits -= 36;\n }\n res.push(bits >>> 3);\n }\n return res;\n})();\n/** All error-correction levels, in spec table order (also the packed-table segment order). */\nconst ECC_LEVELS = ['low', 'medium', 'quartile', 'high'];\n/** ISO/IEC 18004:2024 Table 9: ECC codewords per block, by level (shared with the decoder). */\n// prettier-ignore\nconst WORDS_PER_BLOCK = {\n low: [\n 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28,\n 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n medium: [\n 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26,\n 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n ],\n quartile: [\n 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30,\n 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n high: [\n 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28,\n 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,\n ],\n};\n/** ISO/IEC 18004:2024 Table 9: error-correction block count by version and level. */\n// prettier-ignore\nconst ECC_BLOCKS = {\n low: [1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],\n medium: [1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],\n quartile: [1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],\n high: [1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81],\n};\n/** ISO/IEC 18004:2024 §7.9.1 Table 12: error-correction-level format indicators. */\nconst EC_CODE = { low: 1, medium: 0, quartile: 3, high: 2 };\n/** ISO/IEC 18004:2024 Table 5: alphanumeric characters in value order. */\nconst ALPHANUMERIC = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';\n/**\n * Alignment pattern center coordinates for a version (ISO/IEC 18004:2024\n * Annex E). Exported for custom-design renderers (qrbtf-style module\n * classification): every alignment pattern is centered on (cx, cy) for each\n * pair from this list, except where it would overlap a finder pattern.\n * Coordinates are borderless-symbol module indices.\n */\nfunction alignmentPatterns(ver) {\n ver = asVersion(ver);\n if (ver === 1)\n return [];\n const last = 21 + 4 * (ver - 1) - 7;\n const count = Math.ceil((last - 6) / 28);\n let interval = Math.floor((last - 6) / count);\n if (interval % 2)\n interval += 1;\n else if (((last - 6) % count) * 2 >= count)\n interval += 2;\n const res = [6];\n for (let m = 1; m < count; m++)\n res.push(last - (count - m) * interval);\n res.push(last);\n return res;\n}\n/** BCH-protected masked format word from ISO/IEC 18004:2024 §7.9.1 and Annex C.2. */\nfunction formatBits(ecc, mask) {\n const data = (EC_CODE[ecc] << 3) | mask;\n let d = data;\n for (let i = 0; i < 10; i++)\n d = (d << 1) ^ ((d >> 9) * 0b10100110111);\n return ((data << 10) | d) ^ 0b101010000010010;\n}\n/** Golay-protected 18-bit version word (ISO/IEC 18004:2024 §7.10 / Annex D.2). */\nfunction versionBits(ver) {\n let d = ver;\n for (let i = 0; i < 12; i++)\n d = (d << 1) ^ ((d >> 11) * 0b1111100100101);\n return (ver << 12) | d;\n}\nconst MODE_BITS = { numeric: 1, alphanumeric: 2, byte: 4 };\nconst LENGTH_BITS = {\n numeric: [10, 12, 14],\n alphanumeric: [9, 11, 13],\n byte: [8, 16, 16],\n};\n/**\n * GF(2^8) exp/log tables with the QR primitive polynomial 0x11d. EXP is\n * doubled so products of two logs index it without a mod. Shared with the\n * decoder (it corrects with the same field the encoder generates parity in);\n * the PURE-annotated initializer lets bundlers drop it for consumers that\n * only import the spec tables above.\n */\nconst GF256 = /* @__PURE__ */ (() => {\n const exp = new Uint8Array(510);\n const log = new Uint8Array(256);\n for (let i = 0, x = 1; i < 255; i++) {\n exp[i] = exp[i + 255] = x;\n log[x] = i;\n x <<= 1;\n if (x & 0x100)\n x ^= 0x11d;\n }\n return { exp, log };\n})();\n// Reed-Solomon generator polynomial (leading 1 dropped); one per symbol.\nfunction rsGenerator(eccWords) {\n const { exp: EXP, log: LOG } = GF256;\n const gen = new Uint8Array(eccWords); // coefficients after the leading x^n\n gen[eccWords - 1] = 1;\n for (let i = 0, root = 1; i < eccWords; i++) {\n for (let j = 0; j < eccWords; j++) {\n const c = gen[j];\n gen[j] = (c ? EXP[LOG[c] + LOG[root]] : 0) ^ (j + 1 < eccWords ? gen[j + 1] : 0);\n }\n root = EXP[LOG[root] + 1]; // next power of alpha\n }\n return gen;\n}\nconst RS_CACHE = [];\n// Generator and all coefficient*feedback products, shared by every symbol\n// with the same parity length; entries are generated lazily.\nfunction rsCached(eccWords) {\n let cached = RS_CACHE[eccWords];\n if (cached !== undefined)\n return cached;\n const gen = rsGenerator(eccWords);\n const { exp: EXP, log: LOG } = GF256;\n const mul = new Uint8Array(256 * eccWords);\n for (let f = 1; f < 256; f++) {\n const lf = LOG[f];\n const off = f * eccWords;\n for (let j = 0; j < eccWords; j++) {\n const c = gen[j];\n if (c)\n mul[off + j] = EXP[LOG[c] + lf];\n }\n }\n return (RS_CACHE[eccWords] = { gen, mul });\n}\n// Reed-Solomon parity via LFSR remainder.\nfunction rsEcc(data, gen, mul) {\n const { exp: EXP, log: LOG } = GF256;\n const eccWords = gen.length;\n const res = new Uint8Array(eccWords);\n if (mul !== undefined) {\n const last = eccWords - 1;\n for (let i = 0; i < data.length; i++) {\n const off = (data[i] ^ res[0]) * eccWords;\n for (let j = 0; j < last; j++)\n res[j] = res[j + 1] ^ mul[off + j];\n res[last] = mul[off + last];\n }\n return res;\n }\n for (let i = 0; i < data.length; i++) {\n const f = data[i] ^ res[0];\n res.copyWithin(0, 1);\n res[eccWords - 1] = 0;\n if (f) {\n for (let j = 0; j < eccWords; j++)\n if (gen[j])\n res[j] ^= EXP[LOG[gen[j]] + LOG[f]];\n }\n }\n return res;\n}\nfunction capacity(ver, ecc) {\n const bytes = BYTES[ver - 1];\n const words = WORDS_PER_BLOCK[ecc][ver - 1];\n const numBlocks = ECC_BLOCKS[ecc][ver - 1];\n const blockLen = Math.floor(bytes / numBlocks) - words;\n const shortBlocks = numBlocks - (bytes % numBlocks);\n return { words, numBlocks, shortBlocks, blockLen, capacity: (bytes - words * numBlocks) * 8 };\n}\nconst err = (msg) => {\n throw new Error(msg);\n};\nfunction asVersion(ver) {\n if (typeof ver !== 'number')\n throw new TypeError(`\"ver\" expected number, got type=${typeof ver}`);\n if (!Number.isSafeInteger(ver))\n throw new RangeError(`\"ver\" expected safe integer, got ${ver}`);\n if (ver < 1 || ver > 40)\n throw new RangeError(`Invalid version=${ver}. Expected number [1..40]`);\n return ver;\n}\nfunction detectType(str) {\n let type = 'numeric';\n for (let i = 0; i < str.length; i++) {\n const v = ALNUM_VAL[str.charCodeAt(i)]; // undefined past 127 -> byte\n if (!(v >= 0))\n return 'byte';\n if (v > 9)\n type = 'alphanumeric';\n }\n return type;\n}\n// charCode -> alphanumeric value; -1 outside the Table 5 alphabet. Replaces\n// a 45-char indexOf scan per character in the encode hot path.\nconst ALNUM_VAL = /* @__PURE__ */ (() => {\n const t = new Int8Array(128).fill(-1);\n for (let i = 0; i < ALPHANUMERIC.length; i++)\n t[ALPHANUMERIC.charCodeAt(i)] = i;\n return t;\n})();\n// Segment bits + terminator + padding + RS interleaving.\nfunction encodeData(ver, ecc, text, type, utf8) {\n const cap = capacity(ver, ecc);\n const lengthBits = LENGTH_BITS[type][Math.floor((ver + 7) / 17)];\n const dataLen = type === 'byte' ? utf8.length : text.length;\n if (dataLen >= 1 << lengthBits)\n err('Capacity overflow');\n const bytes = new Uint8Array(cap.capacity >>> 3);\n // MSB-first bit accumulator, flushed a byte at a time. Pushes are <= 16\n // bits and flushing keeps acc below 8 bits, so it never nears 32. Writes\n // past the end fall off the Uint8Array exactly like the old per-bit\n // writer's did; the overflow check below still sees the true bit count.\n let acc = 0;\n let accBits = 0;\n let bytePos = 0;\n const push = (value, len) => {\n acc = (acc << len) | value;\n for (accBits += len; accBits >= 8;)\n bytes[bytePos++] = (acc >>> (accBits -= 8)) & 0xff;\n };\n push(MODE_BITS[type], 4);\n push(dataLen, lengthBits);\n if (type === 'numeric') {\n for (let i = 0; i < dataLen; i += 3) {\n const n = Math.min(3, dataLen - i);\n push(Number(text.slice(i, i + n)), [0, 4, 7, 10][n]);\n }\n }\n else if (type === 'alphanumeric') {\n for (let i = 0; i + 1 < dataLen; i += 2)\n push(ALNUM_VAL[text.charCodeAt(i)] * 45 + ALNUM_VAL[text.charCodeAt(i + 1)], 11);\n if (dataLen & 1)\n push(ALNUM_VAL[text.charCodeAt(dataLen - 1)], 6);\n }\n else {\n for (let i = 0; i < utf8.length; i++)\n push(utf8[i], 8);\n }\n let bitPos = bytePos * 8 + accBits;\n if (bitPos > cap.capacity)\n err('Capacity overflow');\n if (accBits)\n bytes[bytePos] = (acc << (8 - accBits)) & 0xff;\n // Terminator/alignment zeros come from the flush; then pad codewords.\n bitPos += Math.min(4, cap.capacity - bitPos);\n if (bitPos & 7)\n bitPos += 8 - (bitPos & 7);\n for (let i = bitPos >>> 3, pad = 0; i < bytes.length; i++, pad ^= 1)\n bytes[i] = pad ? 0x11 : 0xec;\n // Split into RS blocks (short first), compute parity, interleave both.\n const { words, numBlocks, shortBlocks, blockLen } = cap;\n const rs = rsCached(words);\n const blocks = [];\n const eccs = [];\n for (let i = 0, pos = 0; i < numBlocks; i++) {\n const len = blockLen + (i < shortBlocks ? 0 : 1);\n blocks.push(bytes.subarray(pos, pos + len));\n eccs.push(rsEcc(blocks[i], rs.gen, rs.mul));\n pos += len;\n }\n const res = new Uint8Array(bytes.length + words * numBlocks);\n let p = 0;\n for (let i = 0; i <= blockLen; i++) {\n for (const b of blocks)\n if (i < b.length)\n res[p++] = b[i];\n }\n for (let i = 0; i < words; i++)\n for (const e of eccs)\n res[p++] = e[i];\n return res;\n}\n/**\n * ISO/IEC 18004:2024 Table 10 mask predicates, evaluated arithmetically as an\n * 8-bit vector (bit m set when mask predicate m fires at x,y). Shared with\n * the decoder, which tests a single mask's bit to unmask read modules.\n */\nfunction maskBits(x, y) {\n const x2 = x % 2;\n const y2 = y % 2;\n const x3 = x % 3;\n const xy3 = (x3 * (y % 3)) % 3;\n const xy2 = x2 & y2;\n let bits = 0;\n if (x2 === y2)\n bits |= 1;\n if (y2 === 0)\n bits |= 2;\n if (x3 === 0)\n bits |= 4;\n if ((x + y) % 3 === 0)\n bits |= 8;\n if ((Math.floor(y / 2) + Math.floor(x / 3)) % 2 === 0)\n bits |= 16;\n if (xy2 + xy3 === 0)\n bits |= 32;\n if ((xy2 + xy3) % 2 === 0)\n bits |= 64;\n if (((x2 ^ y2) + xy3) % 2 === 0)\n bits |= 128;\n return bits;\n}\nconst POP16 = /* @__PURE__ */ (() => {\n const t = new Uint8Array(1 << 16);\n for (let i = 1; i < t.length; i++)\n t[i] = t[i >>> 1] + (i & 1);\n return t;\n})();\nconst popcnt = (n) => POP16[n & 0xffff] + POP16[n >>> 16];\nconst TRANSPOSE_TMP = /* @__PURE__ */ new Uint32Array(32);\n// 32x32 in-place bit-matrix transpose (butterfly network).\nfunction transpose32(a) {\n const masks = [0x55555555, 0x33333333, 0x0f0f0f0f, 0x00ff00ff, 0x0000ffff];\n for (let stage = 0; stage < 5; stage++) {\n const m = masks[stage] >>> 0;\n const s = 1 << stage;\n for (let i = 0; i < 32; i += s << 1) {\n for (let k = 0; k < s; k++) {\n const x = a[i + k] >>> 0;\n const y = a[i + k + s] >>> 0;\n const t = ((x >>> s) ^ y) & m;\n a[i + k] = (x ^ (t << s)) >>> 0;\n a[i + k + s] = (y ^ t) >>> 0;\n }\n }\n }\n}\nconst mat = (size) => {\n const words = (size + 31) >>> 5;\n return { size, words, v: new Uint32Array(words * size) };\n};\nconst matGet = (m, x, y) => (m.v[y * m.words + (x >>> 5)] >>> (x & 31)) & 1;\nconst matSet = (m, x, y, bit) => {\n const i = y * m.words + (x >>> 5);\n const b = 1 << (x & 31);\n m.v[i] = bit ? m.v[i] | b : m.v[i] & ~b;\n};\nfunction transposeMat(src, dst) {\n const { size, words, v } = src;\n const tmp = TRANSPOSE_TMP;\n for (let by = 0; by < size; by += 32) {\n for (let bx = 0; bx < words; bx++) {\n const rows = Math.min(32, size - by);\n for (let r = 0; r < rows; r++)\n tmp[r] = v[(by + r) * words + bx];\n tmp.fill(0, rows);\n transpose32(tmp);\n for (let i = 0, dstY = bx * 32; i < 32 && dstY < size; i++, dstY++) {\n dst.v[dstY * dst.words + (by >>> 5)] = tmp[i];\n }\n }\n }\n}\n// N1: runs >= 5 score 3 + (L-5), over all columns at once (32 per stripe).\n// D_y = row^row+1 flags changes; a monochrome 5-window is 4 clear D bits, and\n// each run contributes (L-4) windows plus one run-start window counted twice.\nfunction runsPenaltyVertical(m) {\n const { size, words, v } = m;\n const tail = size & 31 ? ((1 << (size & 31)) - 1) >>> 0 : 0xffffffff;\n let score = 0;\n for (let wi = 0; wi < words; wi++) {\n const valid = wi === words - 1 ? tail : 0xffffffff;\n let r3 = v[3 * words + wi];\n let dPrev = 0xffffffff;\n let d0 = v[wi] ^ v[words + wi];\n let d1 = v[words + wi] ^ v[2 * words + wi];\n let d2 = v[2 * words + wi] ^ r3;\n for (let y = 0, idx = 4 * words + wi; y <= size - 5; y++, idx += words) {\n const r4 = v[idx];\n const d3 = r3 ^ r4;\n const w = ~(d0 | d1 | d2 | d3) & valid;\n if (w)\n score += popcnt(w >>> 0) + 2 * popcnt((w & dPrev) >>> 0);\n dPrev = d0;\n d0 = d1;\n d1 = d2;\n d2 = d3;\n r3 = r4;\n }\n }\n return score;\n}\n// N3: count 1011101 finder ratio with 4 light modules before/after, vertical,\n// both patterns at once across a 32-column stripe.\nfunction finderPenaltyVertical(m) {\n const { size, words, v } = m;\n const tail = size & 31 ? ((1 << (size & 31)) - 1) >>> 0 : 0xffffffff;\n let count = 0;\n for (let wi = 0; wi < words; wi++) {\n const valid = wi === words - 1 ? tail : 0xffffffff;\n for (let y = 0; y <= size - 11; y++) {\n let i = y * words + wi;\n const r0 = v[i];\n const r1 = v[(i += words)];\n const r2 = v[(i += words)];\n const r3 = v[(i += words)];\n const r4 = v[(i += words)];\n const r5 = v[(i += words)];\n const r6 = v[(i += words)];\n const r7 = v[(i += words)];\n const r8 = v[(i += words)];\n const r9 = v[(i += words)];\n const r10 = v[i + words];\n const m0 = valid & r0 & ~r1 & r2 & r3 & r4 & ~r5 & r6 & ~(r7 | r8 | r9 | r10);\n const m1 = valid & ~(r0 | r1 | r2 | r3) & r4 & ~r5 & r6 & r7 & r8 & ~r9 & r10;\n count += popcnt(m0 >>> 0) + popcnt(m1 >>> 0);\n }\n }\n return count;\n}\nfunction penalty(m, t) {\n transposeMat(m, t);\n return penaltyScore(m, t);\n}\n// Score a symbol given both orientations. Split from penalty() so the 8-mask\n// loop can supply a transposed candidate assembled by XOR (transposition is a\n// bit permutation, so T(data^plane) = T(data)^T(plane)) instead of paying a\n// butterfly transpose per mask. `limit` is the best score seen so far in that\n// race: all terms are non-negative, so once a partial sum reaches it this\n// mask can no longer win and the remaining scans — notably the expensive N3\n// finder search — are skipped. The partial is only ever compared to `limit`.\nfunction penaltyScore(m, t, limit = Infinity) {\n const { size, words, v } = m;\n const adjacent = runsPenaltyVertical(m) + runsPenaltyVertical(t);\n if (adjacent >= limit)\n return adjacent;\n // N2: 3 points per 2x2 same-color box (overlapping). Valid left-edge\n // positions in the last word: one less than the bits it actually holds.\n const tail2 = ((1 << (size - 32 * (words - 1) - 1)) - 1) >>> 0;\n let boxes = 0;\n let dark = 0;\n for (let y = 0; y < size; y++) {\n for (let wi = 0; wi < words; wi++) {\n const a0 = v[y * words + wi];\n dark += popcnt(a0 >>> 0);\n if (y === size - 1)\n continue;\n const a1 = v[(y + 1) * words + wi];\n const n0 = wi + 1 < words ? v[y * words + wi + 1] : 0;\n const n1 = wi + 1 < words ? v[(y + 1) * words + wi + 1] : 0;\n const eqV = ~(a0 ^ a1);\n const eqH0 = ~(a0 ^ ((a0 >>> 1) | (n0 << 31)));\n const eqH1 = ~(a1 ^ ((a1 >>> 1) | (n1 << 31)));\n let w = eqV & eqH0 & eqH1;\n if (wi === words - 1)\n w &= tail2;\n boxes += popcnt(w >>> 0);\n }\n }\n const total = size * size;\n const darkSteps = Math.ceil(Math.max(0, Math.abs(dark * 100 - total * 50) - total * 5) / (total * 5));\n const partial = adjacent + 3 * boxes + 10 * darkSteps;\n if (partial >= limit)\n return partial;\n return partial + 40 * (finderPenaltyVertical(m) + finderPenaltyVertical(t));\n}\nfunction drawInfo(m, ver, ecc, mask) {\n const size = m.size;\n const bits = formatBits(ecc, mask);\n for (let i = 0; i < 15; i++) {\n const bit = (bits >> i) & 1;\n // Copy 1 around the top-left finder (skipping the timing row/column).\n if (i < 6)\n matSet(m, 8, i, bit);\n else if (i < 8)\n matSet(m, 8, i + 1, bit);\n else if (i === 8)\n matSet(m, 7, 8, bit);\n else\n matSet(m, 14 - i, 8, bit);\n // Copy 2 under the top-right / right of the bottom-left finder.\n if (i < 8)\n matSet(m, size - 1 - i, 8, bit);\n else\n matSet(m, 8, size - 15 + i, bit);\n }\n matSet(m, 8, size - 8, 1); // dark module\n if (ver >= 7) {\n const vbits = versionBits(ver);\n for (let i = 0; i < 18; i++) {\n const bit = (vbits >> i) & 1;\n const x = size - 11 + (i % 3);\n const y = (i / 3) | 0;\n matSet(m, x, y, bit);\n matSet(m, y, x, bit);\n }\n }\n}\nlet symCache;\nfunction buildSymCache(ver) {\n const size = 21 + 4 * (ver - 1);\n const m = mat(size);\n const fun = new Uint8Array(size * size); // 1 = function or reserved cell\n const setF = (x, y, bit) => {\n matSet(m, x, y, bit);\n fun[y * size + x] = 1;\n };\n // Finder patterns + separators (clipped at the edges).\n for (const [fx, fy] of [\n [0, 0],\n [size - 7, 0],\n [0, size - 7],\n ]) {\n for (let dy = -1; dy < 8; dy++) {\n for (let dx = -1; dx < 8; dx++) {\n const x = fx + dx;\n const y = fy + dy;\n if (x < 0 || y < 0 || x >= size || y >= size)\n continue;\n const on = dx >= 0 &&\n dx < 7 &&\n dy >= 0 &&\n dy < 7 &&\n (dx === 0 || dx === 6 || dy === 0 || dy === 6 || (dx > 1 && dx < 5 && dy > 1 && dy < 5));\n setF(x, y, on ? 1 : 0);\n }\n }\n }\n // Alignment patterns (skip those overlapping finders).\n const align = alignmentPatterns(ver);\n for (const ay of align) {\n for (const ax of align) {\n if (fun[ay * size + ax])\n continue;\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++) {\n const on = Math.max(Math.abs(dx), Math.abs(dy)) !== 1;\n setF(ax + dx, ay + dy, on ? 1 : 0);\n }\n }\n }\n }\n // Timing patterns.\n for (let i = 0; i < size; i++) {\n if (!fun[6 * size + i])\n setF(i, 6, i % 2 === 0 ? 1 : 0);\n if (!fun[i * size + 6])\n setF(6, i, i % 2 === 0 ? 1 : 0);\n }\n // Reserve format / version / dark-module cells at zero (the \"test form\"\n // that mask penalties are scored on, python-qrcode compatible).\n for (let i = 0; i < 9; i++) {\n if (i !== 6) {\n setF(8, i, 0); // column right of the top-left finder, skip timing\n setF(i, 8, 0); // row under the top-left finder\n }\n if (i < 8) {\n setF(size - 1 - i, 8, 0); // under the top-right finder\n setF(8, size - 1 - i, 0); // right of the bottom-left finder + dark module\n }\n }\n if (ver >= 7) {\n for (let i = 0; i < 18; i++) {\n const x = size - 11 + (i % 3);\n const y = (i / 3) | 0;\n setF(x, y, 0);\n setF(y, x, 0);\n }\n }\n // Zigzag placement order + per-mask XOR planes (data region only).\n const planes = [];\n for (let i = 0; i < 8; i++)\n planes.push(mat(size));\n const posBuf = new Uint16Array(size * size);\n let n = 0;\n for (let xOffset = size - 1, dir = -1, y = size - 1; xOffset > 0; xOffset -= 2, dir = -dir) {\n if (xOffset === 6)\n xOffset = 5; // skip the vertical timing column\n for (;; y += dir) {\n for (let j = 0; j < 2; j++) {\n const x = xOffset - j;\n if (fun[y * size + x])\n continue;\n const wi = y * m.words + (x >>> 5);\n posBuf[n++] = (wi << 5) | (x & 31);\n for (let p = 0, mb = maskBits(x, y); mb; p++, mb >>= 1) {\n if (mb & 1)\n planes[p].v[wi] |= 1 << (x & 31);\n }\n }\n if (y + dir < 0 || y + dir >= size)\n break;\n }\n }\n const planesT = planes.map((p) => {\n const t = mat(size);\n transposeMat(p, t);\n return t.v;\n });\n return {\n ver,\n tpl: m.v,\n pos: posBuf.slice(0, n),\n planes: planes.map((p) => p.v),\n planesT,\n work: [mat(size), mat(size), mat(size), mat(size)],\n };\n}\n// Template copy + data-bit scatter along the cached zigzag order, then mask\n// selection: XOR candidates wordwise (both orientations, from the cached\n// transposed planes), score the test form, keep the first lowest\n// (deterministic ties, python-qrcode compatible).\nfunction drawSymbol(ver, ecc, data, maskIdx, test = false) {\n if (symCache === undefined || symCache.ver !== ver)\n symCache = buildSymCache(ver);\n const { tpl, pos, planes, planesT, work } = symCache;\n const [m, t, cand, candT] = work;\n m.v.set(tpl);\n const need = Math.min(8 * data.length, pos.length); // trailing remainder bits stay 0\n for (let i = 0; i < need; i++) {\n if (data[i >>> 3] & (0x80 >>> (i & 7))) {\n const p = pos[i];\n m.v[p >>> 5] |= 1 << (p & 31);\n }\n }\n let mask = maskIdx;\n if (mask === undefined) {\n transposeMat(m, t); // the only transpose per encode; every mask reuses it\n let bestScore = Infinity;\n for (let p = 0; p < 8; p++) {\n const pv = planes[p];\n const ptv = planesT[p];\n for (let i = 0; i < cand.v.length; i++) {\n cand.v[i] = m.v[i] ^ pv[i];\n candT.v[i] = t.v[i] ^ ptv[i];\n }\n const score = penaltyScore(cand, candT, bestScore);\n if (score < bestScore) {\n bestScore = score;\n mask = p;\n }\n }\n }\n const pv = planes[mask];\n for (let i = 0; i < m.v.length; i++)\n m.v[i] ^= pv[i];\n if (!test)\n drawInfo(m, ver, ecc, mask);\n return m;\n}\nconst asNum = (n, title) => {\n if (typeof n !== 'number')\n throw new TypeError(`\"${title}\" expected number, got type=${typeof n}`);\n if (!Number.isSafeInteger(n))\n throw new RangeError(`\"${title}\" expected safe integer, got ${n}`);\n return n;\n};\nconst asString = (s, title) => {\n if (typeof s !== 'string')\n throw new TypeError(`\"${title}\" expected string, got type=${typeof s}`);\n return s;\n};\n// Exact byte count produced by WHATWG TextEncoder, without allocating the\n// encoded buffer. Lone surrogates become the three-byte replacement character.\nfunction utf8Length(str) {\n let length = 0;\n for (let i = 0; i < str.length; i++) {\n const c = str.charCodeAt(i);\n if (c < 0x80)\n length++;\n else if (c < 0x800)\n length += 2;\n else if (c < 0xd800 || c > 0xdfff)\n length += 3;\n else if (c <= 0xdbff && i + 1 < str.length) {\n const next = str.charCodeAt(i + 1);\n if (next >= 0xdc00 && next <= 0xdfff) {\n length += 4;\n i++;\n }\n else\n length += 3;\n }\n else\n length += 3;\n }\n return length;\n}\nfunction byteCapacity(ver, ecc) {\n const lengthBits = LENGTH_BITS.byte[Math.floor((ver + 7) / 17)];\n return Math.min((1 << lengthBits) - 1, Math.floor((capacity(ver, ecc).capacity - 4 - lengthBits) / 8));\n}\n// Copied from noble/hashes utils.ts.\nexport function _isBytes(a) {\n // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.\n // The fallback still requires a real ArrayBuffer view, so plain\n // JSON-deserialized `{ constructor: ... }` spoofing is rejected, and\n // `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.\n return (a instanceof Uint8Array ||\n (ArrayBuffer.isView(a) &&\n a.constructor.name === 'Uint8Array' &&\n 'BYTES_PER_ELEMENT' in a &&\n a.BYTES_PER_ELEMENT === 1));\n}\nconst dark = (r, x, y) => r.map[x] >= 0 && r.map[y] >= 0 && matGet(r.m, r.map[x], r.map[y]) === 1;\n// Control chars come from runtime char codes, never string literals:\n// minifiers re-encode a literal '\\n' — and constant-fold a bare\n// fromCharCode(10) — into a template literal holding a RAW newline\n// (1 byte cheaper), splitting every consumer's single-line .min.js.\n// The array indirection is opaque enough that the fold is skipped.\nconst CTRL = [10, 27]; // [newline, ESC]\nconst NL = /* @__PURE__ */ String.fromCharCode(CTRL[0]);\nfunction renderRaw(r) {\n const W = r.W;\n const res = new Array(W);\n for (let y = 0; y < W; y++) {\n const row = new Array(W);\n for (let x = 0; x < W; x++)\n row[x] = dark(r, x, y);\n res[y] = row;\n }\n return res;\n}\nfunction renderAscii(r) {\n const W = r.W;\n let out = '';\n for (let y = 0; y < W; y += 2) {\n for (let x = 0; x < W; x++) {\n const first = dark(r, x, y);\n const second = y + 1 >= W ? true : dark(r, x, y + 1);\n out += !first && !second ? '█' : !first && second ? '▀' : first && !second ? '▄' : ' ';\n }\n out += NL;\n }\n return out;\n}\nfunction renderTerm(r) {\n const W = r.W;\n const esc = String.fromCharCode(CTRL[1]);\n const reset = esc + '[0m';\n let out = '';\n for (let y = 0; y < W; y++) {\n for (let x = 0; x < W; x++) {\n out += dark(r, x, y) ? `${esc}[40m ${reset}` : `${esc}[1;47m ${reset}`;\n }\n out += NL;\n }\n return out;\n}\nfunction renderSvg(r, optimize) {\n const W = r.W;\n let out = `<svg viewBox=\"0 0 ${W} ${W}\" xmlns=\"http://www.w3.org/2000/svg\">`;\n let pathData = '';\n let prev;\n for (let y = 0; y < W; y++) {\n for (let x = 0; x < W; x++) {\n if (!dark(r, x, y))\n continue;\n if (!optimize) {\n out += `<rect x=\"${x}\" y=\"${y}\" width=\"1\" height=\"1\" />`;\n continue;\n }\n let mv = `M${x} ${y}`;\n if (prev) {\n const rel = `m${x - prev.x} ${y - prev.y}`;\n if (rel.length <= mv.length)\n mv = rel;\n }\n pathData += `${mv}h1v1${x < 10 ? `H${x}` : 'h-1'}Z`;\n prev = { x, y };\n }\n }\n if (optimize)\n out += `<path d=\"${pathData}\"/>`;\n return out + '</svg>';\n}\nfunction renderGif(r) {\n const W = r.W;\n const pixels = W * W;\n const N = 126; // pixels per LZW chunk, 8-bit codes until the next clear\n const fullChunks = Math.floor(pixels / N);\n const tail = pixels % N;\n const out = new Uint8Array(408 + fullChunks * (N + 2) + 2 + tail + 4);\n let p = 0;\n const u16 = (v) => {\n out[p++] = v & 0xff;\n out[p++] = v >>> 8;\n };\n for (const b of [0x47, 0x49, 0x46, 0x38, 0x37, 0x61])\n out[p++] = b; // 'GIF87a'\n u16(W);\n u16(W);\n out[p++] = 0xf6;\n p += 2;\n out[p++] = 0xff;\n out[p++] = 0xff;\n out[p++] = 0xff;\n p += 3 * 127; // palette: 0 = white, 1 = black\n out[p++] = 0x2c;\n p += 4;\n u16(W);\n u16(W);\n out[p++] = 0x00;\n out[p++] = 0x07;\n // Pixels are emitted from a per-module-row 0/1 buffer, rebuilt only when\n // the module row changes (border and scale-repeated output rows reuse it),\n // and block-copied in spans bounded by the LZW chunk boundaries. The span\n // copy is the load-bearing part: a per-pixel emit loop costs more than the\n // bit extraction it wraps, so a row buffer alone measures as no win.\n const { m, map } = r;\n const row = new Uint8Array(W);\n let prevMy = -2;\n for (let y = 0, i = 0; y < W; y++) {\n const my = map[y];\n if (my !== prevMy) {\n prevMy = my;\n row.fill(0);\n if (my >= 0)\n for (let x = 0; x < W; x++)\n if (map[x] >= 0)\n row[x] = matGet(m, map[x], my);\n }\n for (let x = 0; x < W;) {\n if (i % N === 0) {\n const rem = pixels - i;\n out[p++] = (rem < N ? rem : N) + 1;\n out[p++] = 0x80; // LZW clear code\n }\n const n = Math.min(N - (i % N), W - x);\n out.set(row.subarray(x, x + n), p);\n p += n;\n x += n;\n i += n;\n }\n }\n if (tail === 0) {\n out[p++] = 1;\n out[p++] = 0x80;\n }\n out[p++] = 0x01;\n out[p++] = 0x81; // end of information\n out[p++] = 0x00;\n out[p++] = 0x3b;\n return out;\n}\n// data-url: the same GIF, base64-wrapped for direct <img src> use.\n// toBase64 (ES2026) where the engine has it; chunked btoa elsewhere —\n// fromCharCode over the whole buffer would blow the argument-count limit.\nfunction gifDataUrl(gif) {\n const g = gif;\n let b64;\n if (typeof g.toBase64 === 'function')\n b64 = g.toBase64();\n else {\n let bin = '';\n for (let i = 0; i < g.length; i += 8192)\n bin += String.fromCharCode(...g.subarray(i, i + 8192));\n b64 = btoa(bin);\n }\n return 'data:image/gif;base64,' + b64;\n}\nexport function encodeQR(text, output = 'raw', opts = {}) {\n // Validate public arguments, including an explicit version, before caller-controlled encoding.\n asString(text, 'text');\n asString(output, 'output');\n if (typeof opts !== 'object' || opts === null || Array.isArray(opts))\n throw new TypeError(`\"opts\" expected object, got type=${typeof opts}`);\n let ver = opts.version;\n if (ver !== undefined)\n ver = asVersion(ver);\n const ecc = opts.ecc !== undefined ? opts.ecc : 'medium';\n if (!ECC_LEVELS.includes(ecc))\n err(`invalid ecc=${ecc}`);\n const encoding = opts.encoding !== undefined ? opts.encoding : detectType(text);\n if (!LENGTH_BITS[encoding])\n err(`invalid encoding=${encoding}`);\n if (encoding !== 'byte') {\n const alpha = encoding === 'numeric' ? ALPHANUMERIC.slice(0, 10) : ALPHANUMERIC;\n for (const ch of text) {\n if (!alpha.includes(ch))\n err(`Unknown letter: \"${ch}\". Allowed: ${alpha}`);\n }\n }\n if (opts.mask !== undefined && (asNum(opts.mask, 'opts.mask') < 0 || opts.mask > 7))\n err(`invalid mask=${opts.mask}`);\n const textEncoder = opts.textEncoder;\n // Reject impossible built-in UTF-8 payloads before TextEncoder duplicates a\n // potentially huge input. A custom encoder may intentionally emit fewer\n // bytes, so its output remains the source of truth.\n if (encoding === 'byte' && textEncoder === undefined) {\n const maxBytes = byteCapacity(ver === undefined ? 40 : ver, ecc);\n if (text.length > maxBytes || utf8Length(text) > maxBytes)\n err('Capacity overflow');\n }\n const utf8 = encoding === 'byte'\n ? (textEncoder !== undefined ? textEncoder : (s) => new TextEncoder().encode(s))(text)\n : undefined;\n if (utf8 !== undefined && !_isBytes(utf8))\n throw new TypeError(`\"opts.textEncoder\" expected Uint8Array, got type=${typeof utf8}`);\n const dataLen = encoding === 'byte' ? utf8.length : text.length;\n // Encoded payload bit count, for capacity checks without encoding.\n const encodedBits = encoding === 'numeric'\n ? Math.floor(dataLen / 3) * 10 + [0, 4, 7][dataLen % 3]\n : encoding === 'alphanumeric'\n ? Math.floor(dataLen / 2) * 11 + (dataLen % 2) * 6\n : dataLen * 8;\n if (ver === undefined) {\n for (ver = 1; ver <= 40; ver++) {\n const lengthBits = LENGTH_BITS[encoding][Math.floor((ver + 7) / 17)];\n if (dataLen < 1 << lengthBits && 4 + lengthBits + encodedBits <= capacity(ver, ecc).capacity)\n break;\n }\n if (ver > 40)\n err('Capacity overflow');\n }\n else {\n const lengthBits = LENGTH_BITS[encoding][Math.floor((ver + 7) / 17)];\n if (dataLen >= 1 << lengthBits || 4 + lengthBits + encodedBits > capacity(ver, ecc).capacity)\n err('Capacity overflow');\n }\n const data = encodeData(ver, ecc, text, encoding, utf8);\n const m = drawSymbol(ver, ecc, data, opts.mask);\n const border = opts.border === undefined ? 2 : asNum(opts.border, 'opts.border');\n // A quiet zone is required (ISO/IEC 18004:2024 §5.3.8). Consumers that\n // need the borderless module matrix (custom-design renderers like qrbtf /\n // cuer) should request border: 1 and slice the padding ring off — the\n // border is added after the symbol is drawn and never affects its content.\n if (border <= 0)\n throw new RangeError(`invalid border=${border}`);\n const scale = opts.scale === undefined ? 1 : asNum(opts.scale, 'opts.scale');\n if (scale <= 0 || scale > 1024)\n throw new RangeError(`invalid scale factor: ${scale}`);\n // Output dimensions with quiet zone and scaling applied on the fly; `map`\n // translates an output coordinate to its module index (-1 in the border).\n const W = (m.size + 2 * border) * scale;\n // Every renderer does O(W^2) work. Compact outputs can safely use a 4x\n // dimension limit; raw arrays and verbose terminal/SVG strings cannot.\n const maxOutputSize = output === 'ascii' || output === 'gif' || output === 'data-url'\n ? MAX_COMPACT_OUTPUT_SIZE\n : MAX_OUTPUT_SIZE;\n if (W > maxOutputSize)\n throw new RangeError(`invalid opts: output is ${W}x${W} (max ${maxOutputSize}), reduce border/scale`);\n const map = new Int32Array(W);\n for (let i = 0; i < W; i++) {\n const f = Math.floor(i / scale) - border;\n map[i] = f >= 0 && f < m.size ? f : -1;\n }\n const r = { m, W, map };\n if (output === 'raw')\n return renderRaw(r);\n if (output === 'ascii')\n return renderAscii(r);\n if (output === 'term')\n return renderTerm(r);\n if (output === 'svg')\n return renderSvg(r, opts.optimize === undefined ? true : opts.optimize);\n if (output === 'gif')\n return renderGif(r);\n if (output === 'data-url')\n return gifDataUrl(renderGif(r));\n return err(`Unknown output: ${output}`);\n}\n/** Default export alias for {@link encodeQR}. */\nexport default encodeQR;\n// Spec tables and bit-level helpers shared with decode.ts, plus the\n// alignment-pattern table for custom-design renderers. The underscore\n// marks them as private API: undocumented, may change in any release. Named\n// (not bagged in _tests) so decode-only bundles tree-shake per symbol.\nexport { ALPHANUMERIC as _ALPHANUMERIC, alignmentPatterns as _alignmentPatterns, BYTES as _BYTES, ECC_BLOCKS as _ECC_BLOCKS, ECC_LEVELS as _ECC_LEVELS, GF256 as _GF256, WORDS_PER_BLOCK as _WORDS_PER_BLOCK, formatBits as _formatBits, maskBits as _maskBits, popcnt as _popcnt, versionBits as _versionBits, };\n/** Internal helpers exposed for the test suite only. */\nexport const _tests = { mat, matGet, penalty, drawSymbol, encodeData, rsEcc, detectType, EC_CODE, versionBits };\n","import type { BorderGlyphSet } from \"monowind\";\nimport encodeQR from \"qr\";\n\n/**\n * A QR code as grid rows (specs/qr-code.md): the module matrix from\n * the encoder, scaled, then packed into cells by the font's aspect —\n * half blocks where a cell is twice as tall as wide (repeated across\n * cells for taller ones), one full block per module where cells are\n * square, stacked where they are wider than tall. Pure and DOM-free.\n */\n\nexport type Level = \"L\" | \"M\" | \"Q\" | \"H\";\n/** A cell's height over its width, snapped to a packing: `2k` (half\n * blocks, `k` cells per module), `1` (a full block per module), or\n * `1 / m` (one column, `m` rows per module). */\nexport type Aspect = number;\n\n/** The module glyphs a glyph set provides: a full cell, and the two\n * halves when it has them (specs/qr-code.md \"Glyphs through the\n * registry\"). */\nexport interface QrGlyphs {\n full: string;\n upper?: string;\n lower?: string;\n}\n\nexport const DEFAULT_GLYPHS: QrGlyphs = { full: \"█\", upper: \"▀\", lower: \"▄\" };\n\nconst ECC = { L: \"low\", M: \"medium\", Q: \"quartile\", H: \"high\" } as const;\nexport const LEVELS: readonly Level[] = [\"L\", \"M\", \"Q\", \"H\"];\n\nexport interface Encoded {\n /** `modules[y][x]`, true for a dark module. */\n modules: boolean[][];\n version: number;\n /** The level actually used — the requested one, or a higher one the\n * chosen version had room for. */\n level: Level;\n}\n\n/** The borderless matrix, or null when the value overflows: the\n * encoder adds a border of at least one module around the symbol, so\n * one is asked for and sliced off. */\nfunction modulesAt(value: string, level: Level, version?: number): boolean[][] | null {\n try {\n const bordered = encodeQR(value, \"raw\", { ecc: ECC[level], border: 1, version });\n return bordered.slice(1, -1).map((row) => row.slice(1, -1));\n } catch (error) {\n if (error instanceof Error && error.message === \"Capacity overflow\") return null;\n throw error;\n }\n}\n\n/** Encode `value` at the smallest version that holds it at `level`,\n * then raise the level as far as that version allows; null when\n * nothing up to version 40 holds it. */\nexport function encode(value: string, level: Level): Encoded | null {\n let modules = modulesAt(value, level);\n if (!modules) return null;\n const version = (modules.length - 17) / 4;\n let used = level;\n for (const higher of LEVELS.slice(LEVELS.indexOf(level) + 1).reverse()) {\n const boosted = modulesAt(value, higher, version);\n if (boosted) {\n modules = boosted;\n used = higher;\n break;\n }\n }\n return { modules, version, level: used };\n}\n\n/** Every module repeated `n × n`. */\nexport function scaleUp(modules: boolean[][], n: number): boolean[][] {\n if (n === 1) return modules;\n const rows: boolean[][] = [];\n for (const row of modules) {\n const wide = row.flatMap((dark) => Array.from({ length: n }, () => dark));\n for (let i = 0; i < n; i++) rows.push(wide);\n }\n return rows;\n}\n\n/** A cell's measured height over width, snapped to the nearest\n * packing: half blocks `round(ratio / 2)` cells wide from 1.5 up, a\n * full block between, `round(1 / ratio)` full blocks tall from 0.75\n * down. */\nexport function snapAspect(ratio: number): Aspect {\n if (ratio >= 1.5) return 2 * Math.max(1, Math.round(ratio / 2));\n if (ratio <= 0.75) return 1 / Math.max(2, Math.round(1 / ratio));\n return 1;\n}\n\n/** The module glyphs of a set: each role falls back to its default;\n * halves exist when the set declares both or neither, so a set that\n * declares `qrFull` alone has none. */\nexport function resolveGlyphs(set: BorderGlyphSet | undefined): QrGlyphs {\n const solid = set?.solid;\n const full = solid?.qrFull ?? DEFAULT_GLYPHS.full;\n if (solid?.qrUpper && solid.qrLower) return { full, upper: solid.qrUpper, lower: solid.qrLower };\n if (!solid?.qrFull && !solid?.qrUpper && !solid?.qrLower) return { ...DEFAULT_GLYPHS };\n return { full };\n}\n\n/** Pack a (scaled) matrix into rows of cells at a cell aspect (any\n * ratio; snapped). */\nexport function pack(modules: boolean[][], ratio: number, glyphs: QrGlyphs): string[] {\n const aspect = snapAspect(ratio);\n const rows: string[] = [];\n if (aspect >= 2 && glyphs.upper && glyphs.lower) {\n // Two module rows per cell row, each module `aspect / 2` cells\n // wide; an odd count leaves the last lower half light.\n const columns = aspect / 2;\n for (let y = 0; y < modules.length; y += 2) {\n const top = modules[y]!;\n const bottom = modules[y + 1];\n let row = \"\";\n for (let x = 0; x < top.length; x++) {\n const up = top[x]!;\n const down = bottom?.[x] ?? false;\n const glyph = up && down ? glyphs.full : up ? glyphs.upper : down ? glyphs.lower : \" \";\n row += glyph.repeat(columns);\n }\n rows.push(row);\n }\n return rows;\n }\n // Full blocks: a module `aspect` cells wide above 1, `1 / aspect`\n // rows tall below.\n const columns = aspect >= 1 ? aspect : 1;\n const tall = aspect < 1 ? Math.round(1 / aspect) : 1;\n const dark = glyphs.full.repeat(columns);\n const light = \" \".repeat(columns);\n for (const moduleRow of modules) {\n const row = moduleRow.map((on) => (on ? dark : light)).join(\"\");\n for (let i = 0; i < tall; i++) rows.push(row);\n }\n return rows;\n}\n\nexport interface RenderOptions {\n level: Level;\n scale: number;\n /** The cell's height over its width, any ratio. */\n aspect: number;\n glyphs: QrGlyphs;\n}\n\n/** The whole pipeline: rows for `value` (the bare symbol — its quiet\n * zone is the element's padding), or null when it does not fit. */\nexport function renderQr(value: string, options: RenderOptions): string[] | null {\n const encoded = encode(value, options.level);\n if (!encoded) return null;\n return pack(scaleUp(encoded.modules, options.scale), options.aspect, options.glyphs);\n}\n","/**\n * `@monowind/qr-code` — QR codes on the monowind grid: the `<mono-qr>`\n * element, a leaf renderer (specs/leaf-renderers.md, specs/qr-code.md\n * in the monowind repo). The element's text is the value; the grid\n * shows the code packed into cells; the light DOM keeps the value for\n * assistive technology, and a shadow transcript of the rows is what a\n * selection reads.\n */\n\nimport { glyphSetFor, registerLeafRenderer } from \"monowind\";\nimport type { LeafContent } from \"monowind\";\nimport { LEVELS, encode, pack, resolveGlyphs, scaleUp, snapAspect } from \"./render.ts\";\nimport type { Aspect, Encoded, Level } from \"./render.ts\";\n\nexport {\n DEFAULT_GLYPHS,\n encode,\n pack,\n renderQr,\n resolveGlyphs,\n scaleUp,\n snapAspect,\n} from \"./render.ts\";\nexport type { Aspect, Encoded, Level, QrGlyphs, RenderOptions } from \"./render.ts\";\n\n// Import-safe outside the browser (SSR, Node scripts): same guard as\n// the core element.\nconst HTMLElementBase = (\n typeof HTMLElement === \"undefined\" ? class {} : HTMLElement\n) as typeof HTMLElement;\n\n/* The shadow pairs the two representations, as the ascii element's\n * does: a transparent transcript of the rows over the grid (the host\n * inherits the engine's typography lock, so the pre aligns cell for\n * cell) — what a selection reads and a copy pastes — and the slotted\n * value, visually hidden for the accessibility tree. */\nconst SHADOW_TEMPLATE = `<style>\n :host { display: block; }\n #mirror { margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; color: transparent; }\n /* The engine paints a selection on its grid (specs/wide-characters.md);\n * the transcript's own highlight stays invisible, like the light DOM's. */\n #mirror::selection { color: transparent; text-shadow: none; background: transparent; }\n .alt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; user-select: none; -webkit-user-select: none; }\n</style><pre id=\"mirror\" aria-hidden=\"true\"></pre><span class=\"alt\"><slot></slot></span>`;\n\n/** `<mono-qr>`: renders its text content as a QR code. Attributes:\n * `level` (L | M | Q | H, default M), `aspect` (auto, or the cell's\n * height over its width), `scale` (integer ≥ 1). The rows are the\n * bare symbol: its quiet zone is padding the author gives it. */\nexport class MonoQrElement extends HTMLElementBase {\n #mirror: HTMLElement | null = null;\n\n constructor() {\n super();\n const shadow = this.attachShadow({ mode: \"open\" });\n shadow.innerHTML = SHADOW_TEMPLATE;\n this.#mirror = shadow.getElementById(\"mirror\");\n }\n\n /** Keep the transcript in step with the rows (called from the leaf\n * renderer each pass — the shadow is invisible to the engine). */\n syncMirror(lines: string[]): void {\n const text = lines.join(\"\\n\");\n if (this.#mirror && this.#mirror.textContent !== text) this.#mirror.textContent = text;\n }\n}\n\nconst warnedChildren = new WeakSet<Element>();\nconst warnedLength = new WeakSet<Element>();\n\n/** Per element, the last encoding and the last packing, so a layout\n * pass that changes neither costs neither (encoding a long value is\n * milliseconds; `render` runs every pass). */\ninterface Memo {\n encodeKey: string;\n encoded: Encoded | null;\n rowsKey: string;\n rows: string[];\n}\nconst memos = new WeakMap<Element, Memo>();\n/** The matrix grows with the square of `scale`; past this it freezes\n * the tab. */\nconst MAX_SCALE = 16;\n\n/** The rows for an element — the leaf renderer, exported for tests. */\nexport function renderQrLeaf(el: Element): LeafContent {\n const rows = rowsFor(el);\n (el as Partial<MonoQrElement>).syncMirror?.(rows);\n return { lines: rows };\n}\n\nfunction rowsFor(el: Element): string[] {\n const value = (el.textContent ?? \"\").replace(/^[ \\t\\r\\n\\f]+|[ \\t\\r\\n\\f]+$/g, \"\");\n if (el.children.length > 0 && !warnedChildren.has(el)) {\n warnedChildren.add(el);\n console.warn(\"[monowind] <mono-qr> takes text only; element children are ignored.\", el);\n }\n if (!value) return [];\n const level = levelOf(el);\n let memo = memos.get(el);\n if (!memo) memos.set(el, (memo = { encodeKey: \"\", encoded: null, rowsKey: \"\", rows: [] }));\n const encodeKey = `${level}\\0${value}`;\n if (memo.encodeKey !== encodeKey) {\n memo.encodeKey = encodeKey;\n memo.encoded = encode(value, level);\n memo.rowsKey = \"\";\n }\n if (!memo.encoded) {\n if (!warnedLength.has(el)) {\n warnedLength.add(el);\n console.warn(`[monowind] <mono-qr>: the value does not fit a QR code at level ${level}.`, el);\n }\n return [];\n }\n // The measured cell and the glyph set are inherited custom\n // properties: one computed style serves both (none outside a DOM).\n const style = typeof getComputedStyle === \"function\" ? getComputedStyle(el) : null;\n const scale = scaleOf(el);\n const aspect = aspectOf(el, style);\n const glyphs = resolveGlyphs(glyphSetFor(style?.getPropertyValue(\"--mw-border-glyphs\")));\n const rowsKey = `${scale}\\0${aspect}\\0${glyphs.full}\\0${glyphs.upper ?? \"\"}\\0${glyphs.lower ?? \"\"}`;\n if (memo.rowsKey !== rowsKey) {\n memo.rowsKey = rowsKey;\n memo.rows = pack(scaleUp(memo.encoded.modules, scale), aspect, glyphs);\n }\n return memo.rows;\n}\n\nfunction levelOf(el: Element): Level {\n const raw = (el.getAttribute(\"level\") ?? \"M\").toUpperCase() as Level;\n return LEVELS.includes(raw) ? raw : \"M\";\n}\n\n/** `scale`: an integer from 1 to `MAX_SCALE` (larger reads as the\n * max); anything else, an empty attribute included, reads as 1. */\nfunction scaleOf(el: Element): number {\n const value = Number(el.getAttribute(\"scale\") || NaN);\n return Number.isInteger(value) && value >= 1 ? Math.min(value, MAX_SCALE) : 1;\n}\n\n/** `aspect`: an authored ratio, else the measured cell's (the host's\n * `--mw-ch` over `--mw-cw`), else 2 — before the first measurement or\n * without a DOM. */\nfunction aspectOf(el: Element, style: CSSStyleDeclaration | null): Aspect {\n const authored = Number(el.getAttribute(\"aspect\"));\n if (Number.isFinite(authored) && authored > 0) return snapAspect(authored);\n const width = parseFloat(style?.getPropertyValue(\"--mw-cw\") ?? \"\");\n const height = parseFloat(style?.getPropertyValue(\"--mw-ch\") ?? \"\");\n return width > 0 && height > 0 ? snapAspect(height / width) : 2;\n}\n\n/** Idempotent registration of the element + leaf renderer (safe under\n * HMR and multiple entry loads). */\nexport function defineMonoQr(): void {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(\"mono-qr\")) return;\n customElements.define(\"mono-qr\", MonoQrElement);\n registerLeafRenderer({\n tag: \"mono-qr\",\n observedAttributes: [\"level\", \"aspect\", \"scale\"],\n render: renderQrLeaf,\n selectionTarget: (el) => el.shadowRoot?.getElementById(\"mirror\") ?? null,\n });\n}\n\ndefineMonoQr();\n","/* @monowind/qr-code companion stylesheet — import next to monowind's:\n * @import \"tailwindcss\";\n * @import \"monowind\";\n * @import \"@monowind/qr-code\";\n *\n * In `base` so themes and utilities override everything here. */\n\n@layer base {\n /* Custom elements default to inline; the engine's leaf handling\n * gives the block replaced-element sizing (auto width = intrinsic). */\n mono-qr {\n display: block;\n }\n}\n","/**\n * CDN entry — a classic script loaded NEXT TO monowind's own cdn.js:\n *\n * <script src=\".../monowind/dist/cdn.js\"></script>\n * <script src=\".../@monowind/qr-code/dist/cdn.js\"></script>\n *\n * Registers <mono-qr>, injects the companion styles, and merges its\n * version into the shared `monowind` global.\n */\nimport \"./index.ts\";\nimport { encode, renderQr } from \"./render.ts\";\nimport companionCss from \"./styles.css?inline\";\n\nconst style = document.createElement(\"style\");\nstyle.setAttribute(\"data-monowind-qr\", \"\");\nstyle.textContent = companionCss;\ndocument.head.appendChild(style);\n\n// Injected by vite.cdn.config.ts from package.json.\ndeclare const __MONOWIND_QR_VERSION__: string;\n\n// Merge, not replace — core's cdn.js and the other companions share the global.\nconst existing = (globalThis as { monowind?: { qr?: object } }).monowind;\nObject.assign(globalThis, {\n monowind: {\n ...existing,\n qr: { ...existing?.qr, encode, renderQr, version: __MONOWIND_QR_VERSION__ },\n },\n});\n"],"x_google_ignoreList":[0],"mappings":"aAiBA,IAAM,EAAkB,KAClB,EAA0B,EAAkB,EAO5C,OAA+B,CACjC,IAAM,EAAM,CAAC,EACb,IAAK,IAAI,EAAM,EAAG,GAAO,GAAI,IAAO,CAChC,IAAI,GAAQ,GAAK,EAAM,KAAO,EAAM,GACpC,GAAI,GAAO,EAAG,CACV,IAAM,EAAQ,KAAK,MAAM,EAAM,CAAC,EAAI,EACpC,IAAS,GAAK,EAAQ,IAAM,EAAQ,GAChC,GAAO,IACP,GAAQ,GAChB,CACA,EAAI,KAAK,IAAS,CAAC,CACvB,CACA,OAAO,CACX,EAAA,CAAG,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AQ,WAAW,GAAO,iBAAiB,SAAS,GAAK,EAAE,EAC3D,EAAS,WAAW,GAAO,iBAAiB,SAAS,GAAK,EAAE,EAClE,OAAO,EAAQ,GAAK,EAAS,EAAI,EAAW,EAAS,CAAK,EAAI,CAChE,CAIA,SAAgB,IAAqB,CAC/B,OAAO,eAAmB,KAC1B,eAAe,IAAI,SAAS,IAChC,eAAe,OAAO,UAAW,EAAa,GAC9C,EAAA,EAAA,qBAAA,CAAqB,CACnB,IAAK,UACL,mBAAoB,CAAC,QAAS,SAAU,OAAO,EAC/C,OAAQ,GACR,gBAAkB,GAAO,EAAG,YAAY,eAAe,QAAQ,GAAK,IACtE,CAAC,EACH,CAEA,GAAa,+CExJP,EAAQ,SAAS,cAAc,OAAO,EAC5C,EAAM,aAAa,mBAAoB,EAAE,EACzC,EAAM,YAAc,GACpB,SAAS,KAAK,YAAY,CAAK,EAM/B,IAAM,GAAY,WAA8C,SAChE,OAAO,OAAO,WAAY,CACxB,SAAU,CACR,GAAG,GACH,GAAI,CAAE,GAAG,IAAU,GAAI,SAAQ,YAAU,QAAA,OAAiC,CAC5E,CACF,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `@monowind/qr-code` — QR codes on the monowind grid: the `<mono-qr>`
3
+ * element, a leaf renderer (specs/leaf-renderers.md, specs/qr-code.md
4
+ * in the monowind repo). The element's text is the value; the grid
5
+ * shows the code packed into cells; the light DOM keeps the value for
6
+ * assistive technology, and a shadow transcript of the rows is what a
7
+ * selection reads.
8
+ */
9
+ import type { LeafContent } from "monowind";
10
+ export { DEFAULT_GLYPHS, encode, pack, renderQr, resolveGlyphs, scaleUp, snapAspect, } from "./render.ts";
11
+ export type { Aspect, Encoded, Level, QrGlyphs, RenderOptions } from "./render.ts";
12
+ declare const HTMLElementBase: typeof HTMLElement;
13
+ /** `<mono-qr>`: renders its text content as a QR code. Attributes:
14
+ * `level` (L | M | Q | H, default M), `aspect` (auto, or the cell's
15
+ * height over its width), `scale` (integer ≥ 1). The rows are the
16
+ * bare symbol: its quiet zone is padding the author gives it. */
17
+ export declare class MonoQrElement extends HTMLElementBase {
18
+ #private;
19
+ constructor();
20
+ /** Keep the transcript in step with the rows (called from the leaf
21
+ * renderer each pass — the shadow is invisible to the engine). */
22
+ syncMirror(lines: string[]): void;
23
+ }
24
+ /** The rows for an element — the leaf renderer, exported for tests. */
25
+ export declare function renderQrLeaf(el: Element): LeafContent;
26
+ /** Idempotent registration of the element + leaf renderer (safe under
27
+ * HMR and multiple entry loads). */
28
+ export declare function defineMonoQr(): void;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,OAAO,EACL,cAAc,EACd,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,OAAO,EACP,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAInF,QAAA,MAAM,eAAe,EAEhB,OAAO,WAAW,CAAC;AAgBxB;;;iEAGiE;AACjE,qBAAa,aAAc,SAAQ,eAAe;;IAGhD,cAKC;IAED;sEACkE;IAClE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAGhC;CACF;AAmBD,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,WAAW,CAIrD;AA8DD;oCACoC;AACpC,wBAAgB,YAAY,IAAI,IAAI,CAUnC"}
package/dist/index.js ADDED
@@ -0,0 +1,156 @@
1
+ import { glyphSetFor as e, registerLeafRenderer as t } from "monowind";
2
+ import n from "qr";
3
+ //#region src/render.ts
4
+ var r = {
5
+ full: "█",
6
+ upper: "▀",
7
+ lower: "▄"
8
+ }, i = {
9
+ L: "low",
10
+ M: "medium",
11
+ Q: "quartile",
12
+ H: "high"
13
+ }, a = [
14
+ "L",
15
+ "M",
16
+ "Q",
17
+ "H"
18
+ ];
19
+ function o(e, t, r) {
20
+ try {
21
+ return n(e, "raw", {
22
+ ecc: i[t],
23
+ border: 1,
24
+ version: r
25
+ }).slice(1, -1).map((e) => e.slice(1, -1));
26
+ } catch (e) {
27
+ if (e instanceof Error && e.message === "Capacity overflow") return null;
28
+ throw e;
29
+ }
30
+ }
31
+ function s(e, t) {
32
+ let n = o(e, t);
33
+ if (!n) return null;
34
+ let r = (n.length - 17) / 4, i = t;
35
+ for (let s of a.slice(a.indexOf(t) + 1).reverse()) {
36
+ let t = o(e, s, r);
37
+ if (t) {
38
+ n = t, i = s;
39
+ break;
40
+ }
41
+ }
42
+ return {
43
+ modules: n,
44
+ version: r,
45
+ level: i
46
+ };
47
+ }
48
+ function c(e, t) {
49
+ if (t === 1) return e;
50
+ let n = [];
51
+ for (let r of e) {
52
+ let e = r.flatMap((e) => Array.from({ length: t }, () => e));
53
+ for (let r = 0; r < t; r++) n.push(e);
54
+ }
55
+ return n;
56
+ }
57
+ function l(e) {
58
+ return e >= 1.5 ? 2 * Math.max(1, Math.round(e / 2)) : e <= .75 ? 1 / Math.max(2, Math.round(1 / e)) : 1;
59
+ }
60
+ function u(e) {
61
+ let t = e?.solid, n = t?.qrFull ?? r.full;
62
+ return t?.qrUpper && t.qrLower ? {
63
+ full: n,
64
+ upper: t.qrUpper,
65
+ lower: t.qrLower
66
+ } : !t?.qrFull && !t?.qrUpper && !t?.qrLower ? { ...r } : { full: n };
67
+ }
68
+ function d(e, t, n) {
69
+ let r = l(t), i = [];
70
+ if (r >= 2 && n.upper && n.lower) {
71
+ let t = r / 2;
72
+ for (let r = 0; r < e.length; r += 2) {
73
+ let a = e[r], o = e[r + 1], s = "";
74
+ for (let e = 0; e < a.length; e++) {
75
+ let r = a[e], i = o?.[e] ?? !1, c = r && i ? n.full : r ? n.upper : i ? n.lower : " ";
76
+ s += c.repeat(t);
77
+ }
78
+ i.push(s);
79
+ }
80
+ return i;
81
+ }
82
+ let a = r >= 1 ? r : 1, o = r < 1 ? Math.round(1 / r) : 1, s = n.full.repeat(a), c = " ".repeat(a);
83
+ for (let t of e) {
84
+ let e = t.map((e) => e ? s : c).join("");
85
+ for (let t = 0; t < o; t++) i.push(e);
86
+ }
87
+ return i;
88
+ }
89
+ function f(e, t) {
90
+ let n = s(e, t.level);
91
+ return n ? d(c(n.modules, t.scale), t.aspect, t.glyphs) : null;
92
+ }
93
+ //#endregion
94
+ //#region src/index.ts
95
+ var p = typeof HTMLElement > "u" ? class {} : HTMLElement, m = "<style>\n :host { display: block; }\n #mirror { margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; color: transparent; }\n /* The engine paints a selection on its grid (specs/wide-characters.md);\n * the transcript's own highlight stays invisible, like the light DOM's. */\n #mirror::selection { color: transparent; text-shadow: none; background: transparent; }\n .alt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; user-select: none; -webkit-user-select: none; }\n</style><pre id=\"mirror\" aria-hidden=\"true\"></pre><span class=\"alt\"><slot></slot></span>", h = class extends p {
96
+ #e = null;
97
+ constructor() {
98
+ super();
99
+ let e = this.attachShadow({ mode: "open" });
100
+ e.innerHTML = m, this.#e = e.getElementById("mirror");
101
+ }
102
+ syncMirror(e) {
103
+ let t = e.join("\n");
104
+ this.#e && this.#e.textContent !== t && (this.#e.textContent = t);
105
+ }
106
+ }, g = /* @__PURE__ */ new WeakSet(), _ = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakMap(), y = 16;
107
+ function b(e) {
108
+ let t = x(e);
109
+ return e.syncMirror?.(t), { lines: t };
110
+ }
111
+ function x(t) {
112
+ let n = (t.textContent ?? "").replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, "");
113
+ if (t.children.length > 0 && !g.has(t) && (g.add(t), console.warn("[monowind] <mono-qr> takes text only; element children are ignored.", t)), !n) return [];
114
+ let r = S(t), i = v.get(t);
115
+ i || v.set(t, i = {
116
+ encodeKey: "",
117
+ encoded: null,
118
+ rowsKey: "",
119
+ rows: []
120
+ });
121
+ let a = `${r}\0${n}`;
122
+ if (i.encodeKey !== a && (i.encodeKey = a, i.encoded = s(n, r), i.rowsKey = ""), !i.encoded) return _.has(t) || (_.add(t), console.warn(`[monowind] <mono-qr>: the value does not fit a QR code at level ${r}.`, t)), [];
123
+ let o = typeof getComputedStyle == "function" ? getComputedStyle(t) : null, l = C(t), f = w(t, o), p = u(e(o?.getPropertyValue("--mw-border-glyphs"))), m = `${l}\0${f}\0${p.full}\0${p.upper ?? ""}\0${p.lower ?? ""}`;
124
+ return i.rowsKey !== m && (i.rowsKey = m, i.rows = d(c(i.encoded.modules, l), f, p)), i.rows;
125
+ }
126
+ function S(e) {
127
+ let t = (e.getAttribute("level") ?? "M").toUpperCase();
128
+ return a.includes(t) ? t : "M";
129
+ }
130
+ function C(e) {
131
+ let t = Number(e.getAttribute("scale") || NaN);
132
+ return Number.isInteger(t) && t >= 1 ? Math.min(t, y) : 1;
133
+ }
134
+ function w(e, t) {
135
+ let n = Number(e.getAttribute("aspect"));
136
+ if (Number.isFinite(n) && n > 0) return l(n);
137
+ let r = parseFloat(t?.getPropertyValue("--mw-cw") ?? ""), i = parseFloat(t?.getPropertyValue("--mw-ch") ?? "");
138
+ return r > 0 && i > 0 ? l(i / r) : 2;
139
+ }
140
+ function T() {
141
+ typeof customElements > "u" || customElements.get("mono-qr") || (customElements.define("mono-qr", h), t({
142
+ tag: "mono-qr",
143
+ observedAttributes: [
144
+ "level",
145
+ "aspect",
146
+ "scale"
147
+ ],
148
+ render: b,
149
+ selectionTarget: (e) => e.shadowRoot?.getElementById("mirror") ?? null
150
+ }));
151
+ }
152
+ T();
153
+ //#endregion
154
+ export { r as DEFAULT_GLYPHS, h as MonoQrElement, T as defineMonoQr, s as encode, d as pack, f as renderQr, b as renderQrLeaf, u as resolveGlyphs, c as scaleUp, l as snapAspect };
155
+
156
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/render.ts","../src/index.ts"],"sourcesContent":["import type { BorderGlyphSet } from \"monowind\";\nimport encodeQR from \"qr\";\n\n/**\n * A QR code as grid rows (specs/qr-code.md): the module matrix from\n * the encoder, scaled, then packed into cells by the font's aspect —\n * half blocks where a cell is twice as tall as wide (repeated across\n * cells for taller ones), one full block per module where cells are\n * square, stacked where they are wider than tall. Pure and DOM-free.\n */\n\nexport type Level = \"L\" | \"M\" | \"Q\" | \"H\";\n/** A cell's height over its width, snapped to a packing: `2k` (half\n * blocks, `k` cells per module), `1` (a full block per module), or\n * `1 / m` (one column, `m` rows per module). */\nexport type Aspect = number;\n\n/** The module glyphs a glyph set provides: a full cell, and the two\n * halves when it has them (specs/qr-code.md \"Glyphs through the\n * registry\"). */\nexport interface QrGlyphs {\n full: string;\n upper?: string;\n lower?: string;\n}\n\nexport const DEFAULT_GLYPHS: QrGlyphs = { full: \"█\", upper: \"▀\", lower: \"▄\" };\n\nconst ECC = { L: \"low\", M: \"medium\", Q: \"quartile\", H: \"high\" } as const;\nexport const LEVELS: readonly Level[] = [\"L\", \"M\", \"Q\", \"H\"];\n\nexport interface Encoded {\n /** `modules[y][x]`, true for a dark module. */\n modules: boolean[][];\n version: number;\n /** The level actually used — the requested one, or a higher one the\n * chosen version had room for. */\n level: Level;\n}\n\n/** The borderless matrix, or null when the value overflows: the\n * encoder adds a border of at least one module around the symbol, so\n * one is asked for and sliced off. */\nfunction modulesAt(value: string, level: Level, version?: number): boolean[][] | null {\n try {\n const bordered = encodeQR(value, \"raw\", { ecc: ECC[level], border: 1, version });\n return bordered.slice(1, -1).map((row) => row.slice(1, -1));\n } catch (error) {\n if (error instanceof Error && error.message === \"Capacity overflow\") return null;\n throw error;\n }\n}\n\n/** Encode `value` at the smallest version that holds it at `level`,\n * then raise the level as far as that version allows; null when\n * nothing up to version 40 holds it. */\nexport function encode(value: string, level: Level): Encoded | null {\n let modules = modulesAt(value, level);\n if (!modules) return null;\n const version = (modules.length - 17) / 4;\n let used = level;\n for (const higher of LEVELS.slice(LEVELS.indexOf(level) + 1).reverse()) {\n const boosted = modulesAt(value, higher, version);\n if (boosted) {\n modules = boosted;\n used = higher;\n break;\n }\n }\n return { modules, version, level: used };\n}\n\n/** Every module repeated `n × n`. */\nexport function scaleUp(modules: boolean[][], n: number): boolean[][] {\n if (n === 1) return modules;\n const rows: boolean[][] = [];\n for (const row of modules) {\n const wide = row.flatMap((dark) => Array.from({ length: n }, () => dark));\n for (let i = 0; i < n; i++) rows.push(wide);\n }\n return rows;\n}\n\n/** A cell's measured height over width, snapped to the nearest\n * packing: half blocks `round(ratio / 2)` cells wide from 1.5 up, a\n * full block between, `round(1 / ratio)` full blocks tall from 0.75\n * down. */\nexport function snapAspect(ratio: number): Aspect {\n if (ratio >= 1.5) return 2 * Math.max(1, Math.round(ratio / 2));\n if (ratio <= 0.75) return 1 / Math.max(2, Math.round(1 / ratio));\n return 1;\n}\n\n/** The module glyphs of a set: each role falls back to its default;\n * halves exist when the set declares both or neither, so a set that\n * declares `qrFull` alone has none. */\nexport function resolveGlyphs(set: BorderGlyphSet | undefined): QrGlyphs {\n const solid = set?.solid;\n const full = solid?.qrFull ?? DEFAULT_GLYPHS.full;\n if (solid?.qrUpper && solid.qrLower) return { full, upper: solid.qrUpper, lower: solid.qrLower };\n if (!solid?.qrFull && !solid?.qrUpper && !solid?.qrLower) return { ...DEFAULT_GLYPHS };\n return { full };\n}\n\n/** Pack a (scaled) matrix into rows of cells at a cell aspect (any\n * ratio; snapped). */\nexport function pack(modules: boolean[][], ratio: number, glyphs: QrGlyphs): string[] {\n const aspect = snapAspect(ratio);\n const rows: string[] = [];\n if (aspect >= 2 && glyphs.upper && glyphs.lower) {\n // Two module rows per cell row, each module `aspect / 2` cells\n // wide; an odd count leaves the last lower half light.\n const columns = aspect / 2;\n for (let y = 0; y < modules.length; y += 2) {\n const top = modules[y]!;\n const bottom = modules[y + 1];\n let row = \"\";\n for (let x = 0; x < top.length; x++) {\n const up = top[x]!;\n const down = bottom?.[x] ?? false;\n const glyph = up && down ? glyphs.full : up ? glyphs.upper : down ? glyphs.lower : \" \";\n row += glyph.repeat(columns);\n }\n rows.push(row);\n }\n return rows;\n }\n // Full blocks: a module `aspect` cells wide above 1, `1 / aspect`\n // rows tall below.\n const columns = aspect >= 1 ? aspect : 1;\n const tall = aspect < 1 ? Math.round(1 / aspect) : 1;\n const dark = glyphs.full.repeat(columns);\n const light = \" \".repeat(columns);\n for (const moduleRow of modules) {\n const row = moduleRow.map((on) => (on ? dark : light)).join(\"\");\n for (let i = 0; i < tall; i++) rows.push(row);\n }\n return rows;\n}\n\nexport interface RenderOptions {\n level: Level;\n scale: number;\n /** The cell's height over its width, any ratio. */\n aspect: number;\n glyphs: QrGlyphs;\n}\n\n/** The whole pipeline: rows for `value` (the bare symbol — its quiet\n * zone is the element's padding), or null when it does not fit. */\nexport function renderQr(value: string, options: RenderOptions): string[] | null {\n const encoded = encode(value, options.level);\n if (!encoded) return null;\n return pack(scaleUp(encoded.modules, options.scale), options.aspect, options.glyphs);\n}\n","/**\n * `@monowind/qr-code` — QR codes on the monowind grid: the `<mono-qr>`\n * element, a leaf renderer (specs/leaf-renderers.md, specs/qr-code.md\n * in the monowind repo). The element's text is the value; the grid\n * shows the code packed into cells; the light DOM keeps the value for\n * assistive technology, and a shadow transcript of the rows is what a\n * selection reads.\n */\n\nimport { glyphSetFor, registerLeafRenderer } from \"monowind\";\nimport type { LeafContent } from \"monowind\";\nimport { LEVELS, encode, pack, resolveGlyphs, scaleUp, snapAspect } from \"./render.ts\";\nimport type { Aspect, Encoded, Level } from \"./render.ts\";\n\nexport {\n DEFAULT_GLYPHS,\n encode,\n pack,\n renderQr,\n resolveGlyphs,\n scaleUp,\n snapAspect,\n} from \"./render.ts\";\nexport type { Aspect, Encoded, Level, QrGlyphs, RenderOptions } from \"./render.ts\";\n\n// Import-safe outside the browser (SSR, Node scripts): same guard as\n// the core element.\nconst HTMLElementBase = (\n typeof HTMLElement === \"undefined\" ? class {} : HTMLElement\n) as typeof HTMLElement;\n\n/* The shadow pairs the two representations, as the ascii element's\n * does: a transparent transcript of the rows over the grid (the host\n * inherits the engine's typography lock, so the pre aligns cell for\n * cell) — what a selection reads and a copy pastes — and the slotted\n * value, visually hidden for the accessibility tree. */\nconst SHADOW_TEMPLATE = `<style>\n :host { display: block; }\n #mirror { margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; color: transparent; }\n /* The engine paints a selection on its grid (specs/wide-characters.md);\n * the transcript's own highlight stays invisible, like the light DOM's. */\n #mirror::selection { color: transparent; text-shadow: none; background: transparent; }\n .alt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; user-select: none; -webkit-user-select: none; }\n</style><pre id=\"mirror\" aria-hidden=\"true\"></pre><span class=\"alt\"><slot></slot></span>`;\n\n/** `<mono-qr>`: renders its text content as a QR code. Attributes:\n * `level` (L | M | Q | H, default M), `aspect` (auto, or the cell's\n * height over its width), `scale` (integer ≥ 1). The rows are the\n * bare symbol: its quiet zone is padding the author gives it. */\nexport class MonoQrElement extends HTMLElementBase {\n #mirror: HTMLElement | null = null;\n\n constructor() {\n super();\n const shadow = this.attachShadow({ mode: \"open\" });\n shadow.innerHTML = SHADOW_TEMPLATE;\n this.#mirror = shadow.getElementById(\"mirror\");\n }\n\n /** Keep the transcript in step with the rows (called from the leaf\n * renderer each pass — the shadow is invisible to the engine). */\n syncMirror(lines: string[]): void {\n const text = lines.join(\"\\n\");\n if (this.#mirror && this.#mirror.textContent !== text) this.#mirror.textContent = text;\n }\n}\n\nconst warnedChildren = new WeakSet<Element>();\nconst warnedLength = new WeakSet<Element>();\n\n/** Per element, the last encoding and the last packing, so a layout\n * pass that changes neither costs neither (encoding a long value is\n * milliseconds; `render` runs every pass). */\ninterface Memo {\n encodeKey: string;\n encoded: Encoded | null;\n rowsKey: string;\n rows: string[];\n}\nconst memos = new WeakMap<Element, Memo>();\n/** The matrix grows with the square of `scale`; past this it freezes\n * the tab. */\nconst MAX_SCALE = 16;\n\n/** The rows for an element — the leaf renderer, exported for tests. */\nexport function renderQrLeaf(el: Element): LeafContent {\n const rows = rowsFor(el);\n (el as Partial<MonoQrElement>).syncMirror?.(rows);\n return { lines: rows };\n}\n\nfunction rowsFor(el: Element): string[] {\n const value = (el.textContent ?? \"\").replace(/^[ \\t\\r\\n\\f]+|[ \\t\\r\\n\\f]+$/g, \"\");\n if (el.children.length > 0 && !warnedChildren.has(el)) {\n warnedChildren.add(el);\n console.warn(\"[monowind] <mono-qr> takes text only; element children are ignored.\", el);\n }\n if (!value) return [];\n const level = levelOf(el);\n let memo = memos.get(el);\n if (!memo) memos.set(el, (memo = { encodeKey: \"\", encoded: null, rowsKey: \"\", rows: [] }));\n const encodeKey = `${level}\\0${value}`;\n if (memo.encodeKey !== encodeKey) {\n memo.encodeKey = encodeKey;\n memo.encoded = encode(value, level);\n memo.rowsKey = \"\";\n }\n if (!memo.encoded) {\n if (!warnedLength.has(el)) {\n warnedLength.add(el);\n console.warn(`[monowind] <mono-qr>: the value does not fit a QR code at level ${level}.`, el);\n }\n return [];\n }\n // The measured cell and the glyph set are inherited custom\n // properties: one computed style serves both (none outside a DOM).\n const style = typeof getComputedStyle === \"function\" ? getComputedStyle(el) : null;\n const scale = scaleOf(el);\n const aspect = aspectOf(el, style);\n const glyphs = resolveGlyphs(glyphSetFor(style?.getPropertyValue(\"--mw-border-glyphs\")));\n const rowsKey = `${scale}\\0${aspect}\\0${glyphs.full}\\0${glyphs.upper ?? \"\"}\\0${glyphs.lower ?? \"\"}`;\n if (memo.rowsKey !== rowsKey) {\n memo.rowsKey = rowsKey;\n memo.rows = pack(scaleUp(memo.encoded.modules, scale), aspect, glyphs);\n }\n return memo.rows;\n}\n\nfunction levelOf(el: Element): Level {\n const raw = (el.getAttribute(\"level\") ?? \"M\").toUpperCase() as Level;\n return LEVELS.includes(raw) ? raw : \"M\";\n}\n\n/** `scale`: an integer from 1 to `MAX_SCALE` (larger reads as the\n * max); anything else, an empty attribute included, reads as 1. */\nfunction scaleOf(el: Element): number {\n const value = Number(el.getAttribute(\"scale\") || NaN);\n return Number.isInteger(value) && value >= 1 ? Math.min(value, MAX_SCALE) : 1;\n}\n\n/** `aspect`: an authored ratio, else the measured cell's (the host's\n * `--mw-ch` over `--mw-cw`), else 2 — before the first measurement or\n * without a DOM. */\nfunction aspectOf(el: Element, style: CSSStyleDeclaration | null): Aspect {\n const authored = Number(el.getAttribute(\"aspect\"));\n if (Number.isFinite(authored) && authored > 0) return snapAspect(authored);\n const width = parseFloat(style?.getPropertyValue(\"--mw-cw\") ?? \"\");\n const height = parseFloat(style?.getPropertyValue(\"--mw-ch\") ?? \"\");\n return width > 0 && height > 0 ? snapAspect(height / width) : 2;\n}\n\n/** Idempotent registration of the element + leaf renderer (safe under\n * HMR and multiple entry loads). */\nexport function defineMonoQr(): void {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(\"mono-qr\")) return;\n customElements.define(\"mono-qr\", MonoQrElement);\n registerLeafRenderer({\n tag: \"mono-qr\",\n observedAttributes: [\"level\", \"aspect\", \"scale\"],\n render: renderQrLeaf,\n selectionTarget: (el) => el.shadowRoot?.getElementById(\"mirror\") ?? null,\n });\n}\n\ndefineMonoQr();\n"],"mappings":";;;AA0BA,IAAa,IAA2B;CAAE,MAAM;CAAK,OAAO;CAAK,OAAO;AAAI,GAEtE,IAAM;CAAE,GAAG;CAAO,GAAG;CAAU,GAAG;CAAY,GAAG;AAAO,GACjD,IAA2B;CAAC;CAAK;CAAK;CAAK;AAAG;AAc3D,SAAS,EAAU,GAAe,GAAc,GAAsC;CACpF,IAAI;EAEF,OADiB,EAAS,GAAO,OAAO;GAAE,KAAK,EAAI;GAAQ,QAAQ;GAAG;EAAQ,CACvE,CAAA,CAAS,MAAM,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G,YAAY,eAAe,QAAQ,KAAK;CACtE,CAAC;AACH;AAEA,EAAa"}
@@ -0,0 +1,60 @@
1
+ import type { BorderGlyphSet } from "monowind";
2
+ /**
3
+ * A QR code as grid rows (specs/qr-code.md): the module matrix from
4
+ * the encoder, scaled, then packed into cells by the font's aspect —
5
+ * half blocks where a cell is twice as tall as wide (repeated across
6
+ * cells for taller ones), one full block per module where cells are
7
+ * square, stacked where they are wider than tall. Pure and DOM-free.
8
+ */
9
+ export type Level = "L" | "M" | "Q" | "H";
10
+ /** A cell's height over its width, snapped to a packing: `2k` (half
11
+ * blocks, `k` cells per module), `1` (a full block per module), or
12
+ * `1 / m` (one column, `m` rows per module). */
13
+ export type Aspect = number;
14
+ /** The module glyphs a glyph set provides: a full cell, and the two
15
+ * halves when it has them (specs/qr-code.md "Glyphs through the
16
+ * registry"). */
17
+ export interface QrGlyphs {
18
+ full: string;
19
+ upper?: string;
20
+ lower?: string;
21
+ }
22
+ export declare const DEFAULT_GLYPHS: QrGlyphs;
23
+ export declare const LEVELS: readonly Level[];
24
+ export interface Encoded {
25
+ /** `modules[y][x]`, true for a dark module. */
26
+ modules: boolean[][];
27
+ version: number;
28
+ /** The level actually used — the requested one, or a higher one the
29
+ * chosen version had room for. */
30
+ level: Level;
31
+ }
32
+ /** Encode `value` at the smallest version that holds it at `level`,
33
+ * then raise the level as far as that version allows; null when
34
+ * nothing up to version 40 holds it. */
35
+ export declare function encode(value: string, level: Level): Encoded | null;
36
+ /** Every module repeated `n × n`. */
37
+ export declare function scaleUp(modules: boolean[][], n: number): boolean[][];
38
+ /** A cell's measured height over width, snapped to the nearest
39
+ * packing: half blocks `round(ratio / 2)` cells wide from 1.5 up, a
40
+ * full block between, `round(1 / ratio)` full blocks tall from 0.75
41
+ * down. */
42
+ export declare function snapAspect(ratio: number): Aspect;
43
+ /** The module glyphs of a set: each role falls back to its default;
44
+ * halves exist when the set declares both or neither, so a set that
45
+ * declares `qrFull` alone has none. */
46
+ export declare function resolveGlyphs(set: BorderGlyphSet | undefined): QrGlyphs;
47
+ /** Pack a (scaled) matrix into rows of cells at a cell aspect (any
48
+ * ratio; snapped). */
49
+ export declare function pack(modules: boolean[][], ratio: number, glyphs: QrGlyphs): string[];
50
+ export interface RenderOptions {
51
+ level: Level;
52
+ scale: number;
53
+ /** The cell's height over its width, any ratio. */
54
+ aspect: number;
55
+ glyphs: QrGlyphs;
56
+ }
57
+ /** The whole pipeline: rows for `value` (the bare symbol — its quiet
58
+ * zone is the element's padding), or null when it does not fit. */
59
+ export declare function renderQr(value: string, options: RenderOptions): string[] | null;
60
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C;;;;;;GAMG;AAEH,MAAM,MAAM,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC1C;;gDAEgD;AAChD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;iBAEiB;AACjB,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,EAAE,QAAgD,CAAC;AAG9E,eAAO,MAAM,MAAM,EAAE,SAAS,KAAK,EAAyB,CAAC;AAE7D,MAAM,WAAW,OAAO;IACtB,+CAA+C;IAC/C,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB;sCACkC;IAClC,KAAK,EAAE,KAAK,CAAC;CACd;AAeD;;wCAEwC;AACxC,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI,CAclE;AAED,qCAAqC;AACrC,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,EAAE,CAQpE;AAED;;;WAGW;AACX,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;uCAEuC;AACvC,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,SAAS,GAAG,QAAQ,CAMvE;AAED;sBACsB;AACtB,wBAAgB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,CAgCpF;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED;mEACmE;AACnE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,GAAG,IAAI,CAI/E"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@monowind/qr-code",
3
+ "version": "0.2.9",
4
+ "description": "QR codes on the monowind grid: the <mono-qr> element",
5
+ "keywords": [
6
+ "monowind",
7
+ "qr",
8
+ "qr-code",
9
+ "tui"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "Benoît Rouleau",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/benface/monowind.git",
16
+ "directory": "packages/qr-code"
17
+ },
18
+ "style": "./src/styles.css",
19
+ "files": [
20
+ "dist",
21
+ "src/*.css"
22
+ ],
23
+ "type": "module",
24
+ "sideEffects": [
25
+ "./src/index.ts",
26
+ "./dist/index.js"
27
+ ],
28
+ "exports": {
29
+ ".": {
30
+ "style": "./src/styles.css",
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./styles.css": "./src/styles.css",
35
+ "./package.json": "./package.json"
36
+ },
37
+ "dependencies": {
38
+ "qr": "^0.7.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^26.4.1",
42
+ "happy-dom": "^20.14.0",
43
+ "monowind": "^0.2.9",
44
+ "typescript": "^7.0.2",
45
+ "vite": "^8.2.2",
46
+ "vitest": "^4.1.11"
47
+ },
48
+ "peerDependencies": {
49
+ "monowind": "^0.2.9"
50
+ },
51
+ "scripts": {
52
+ "build": "vite build && vite build -c vite.cdn.config.ts && tsc -p tsconfig.build.json",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "vitest run",
55
+ "test:watch": "vitest"
56
+ }
57
+ }
package/src/styles.css ADDED
@@ -0,0 +1,14 @@
1
+ /* @monowind/qr-code companion stylesheet — import next to monowind's:
2
+ * @import "tailwindcss";
3
+ * @import "monowind";
4
+ * @import "@monowind/qr-code";
5
+ *
6
+ * In `base` so themes and utilities override everything here. */
7
+
8
+ @layer base {
9
+ /* Custom elements default to inline; the engine's leaf handling
10
+ * gives the block replaced-element sizing (auto width = intrinsic). */
11
+ mono-qr {
12
+ display: block;
13
+ }
14
+ }