responsivelint 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -2
  3. package/agents/skills/responsivelint/SKILL.md +57 -0
  4. package/agents/skills/responsivelint-fix/SKILL.md +38 -0
  5. package/agents/skills/responsivelint-fix-controls/SKILL.md +35 -0
  6. package/agents/skills/responsivelint-fix-cramped-text/SKILL.md +47 -0
  7. package/agents/skills/responsivelint-fix-overflow/SKILL.md +33 -0
  8. package/agents/skills/responsivelint-fix-overlap/SKILL.md +33 -0
  9. package/bin/responsivelint.mjs +111 -0
  10. package/dist/core.iife.js +944 -0
  11. package/dist/responsivelint.js +1232 -0
  12. package/dist/responsivelint.min.js +25 -0
  13. package/docs/rules/clipped-text.md +21 -0
  14. package/docs/rules/disappears-in-band.md +21 -0
  15. package/docs/rules/hidden-control.md +21 -0
  16. package/docs/rules/page-overflow.md +21 -0
  17. package/docs/rules/squashed-text.md +21 -0
  18. package/docs/rules/text-overlap.md +21 -0
  19. package/docs/rules/width-outlier.md +21 -0
  20. package/llms.txt +49 -0
  21. package/package.json +43 -4
  22. package/src/browser/entry.js +337 -0
  23. package/src/cli/replay.js +86 -0
  24. package/src/cli/report.js +90 -0
  25. package/src/cli/run.js +241 -0
  26. package/src/cli/server.js +24 -0
  27. package/src/core/analyze.js +265 -0
  28. package/src/core/bar.js +78 -0
  29. package/src/core/dom.js +122 -0
  30. package/src/core/highlight.js +73 -0
  31. package/src/core/index.js +5 -0
  32. package/src/core/inject.js +5 -0
  33. package/src/core/measure.js +241 -0
  34. package/src/core/recipe.js +19 -0
  35. package/src/explore/page.js +63 -0
  36. package/src/icons/measure.js +106 -0
  37. package/src/index.js +5 -0
@@ -0,0 +1,25 @@
1
+ (()=>{var J=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","TITLE","OPTION","HEAD","META","LINK"]),lt=["button","a[href]","summary","select","textarea","input:not([type=hidden])","[role=button]","[role=tab]","[role=link]","[role=menuitem]","[role=switch]","[role=checkbox]","[role=option]",'[tabindex]:not([tabindex="-1"])'].join(",");function R(n){let e=[];for(let i=n;i&&i.nodeType===1&&i!==document.body&&i!==document.documentElement;i=i.parentElement){if(i.id&&/^[A-Za-z][\w-]*$/.test(i.id))return e.unshift("#"+i.id),e.join(">");let h=i.parentElement,r=h?Array.prototype.indexOf.call(h.children,i)+1:1;e.unshift(i.tagName.toLowerCase()+":nth-child("+r+")")}return e.unshift("body"),e.join(">")}function P(n){let e=new Set;for(let i=n;i&&i.nodeType===1;i=i.parentElement){let h=i.getAttribute&&i.getAttribute("data-rl-ignore");h!=null&&(h===""||h==="all"?e.add("all"):h.split(/[\s,]+/).forEach(r=>e.add(r)))}return e}function ct(){let n=new Map,e=new Map,i=new Map,h=new Map,r=o=>{let s=n.get(o);return s||(s=getComputedStyle(o),n.set(o,s)),s};function p(o){if(!o||o.nodeType!==1)return 1;if(e.has(o))return e.get(o);let s=parseFloat(r(o).opacity||"1")*p(o.parentElement);return e.set(o,s),s}function c(o){if(!o||o.nodeType!==1)return!1;if(h.has(o))return h.get(o);let s=r(o).position,u=s==="fixed"||s==="sticky"||c(o.parentElement);return h.set(o,u),u}function g(o){if(!o||o.nodeType!==1||o===document.documentElement)return{left:-1e9,top:-1e9,right:1e9,bottom:1e9};if(i.has(o))return i.get(o);let s=g(o.parentElement),u=r(o),b=s;if(o!==document.body&&(u.overflowX!=="visible"||u.overflowY!=="visible")){let m=o.getBoundingClientRect(),t={left:m.left+scrollX+o.clientLeft,top:m.top+scrollY+o.clientTop};t.right=t.left+o.clientWidth,t.bottom=t.top+o.clientHeight,b={left:u.overflowX==="visible"?s.left:Math.max(s.left,t.left),right:u.overflowX==="visible"?s.right:Math.min(s.right,t.right),top:u.overflowY==="visible"?s.top:Math.max(s.top,t.top),bottom:u.overflowY==="visible"?s.bottom:Math.min(s.bottom,t.bottom)}}return u.position==="fixed"&&(b={left:-1e9,top:-1e9,right:1e9,bottom:1e9}),i.set(o,b),b}function f(o){for(let u=o;u&&u.nodeType===1;u=u.parentElement)if(u.getAttribute("aria-hidden")==="true"||u.hasAttribute("inert")||u.hidden)return!0;let s=r(o);return s.visibility!=="visible"||s.display==="none"||s.contentVisibility==="hidden"}return{cs:r,effectiveOpacity:p,isPinned:c,clipRect:g,hidden:f}}var z=(n,e)=>({left:Math.max(n.left,e.left),top:Math.max(n.top,e.top),right:Math.min(n.right,e.right),bottom:Math.min(n.bottom,e.bottom)}),I=n=>Math.max(0,n.right-n.left)*Math.max(0,n.bottom-n.top);function dt(n,e){let i=[],h="",r=e.clipRect(n);for(let p of n.childNodes){if(p.nodeType!==3||!p.textContent.trim())continue;h+=p.textContent;let c=document.createRange();c.selectNodeContents(p);for(let g of c.getClientRects()){if(g.width<1||g.height<1)continue;let f={left:g.left+scrollX,top:g.top+scrollY,right:g.right+scrollX,bottom:g.bottom+scrollY},o=z(f,r);I(o)>0&&i.push(o)}}return{text:h.replace(/\s+/g," ").trim(),rects:i}}function ht(n){let e=n.map(r=>(r.top+r.bottom)/2).sort((r,p)=>r-p),i=0,h=-1e9;for(let r of e)r-h>3&&(i++,h=r);return i}function Y(n,e){return(n.getAttribute("aria-label")||e||n.getAttribute("title")||n.getAttribute("alt")||"").replace(/\s+/g," ").trim().slice(0,60)}var $t=4e3,pt=2500;function Q(){let n=globalThis,e=[];n.__THREE__&&e.push("three.js r"+n.__THREE__),n.AFRAME&&e.push("A-Frame "+(n.AFRAME.version||"")),n.BABYLON&&e.push("Babylon.js "+(n.BABYLON.Engine?.Version||"")),n.pc&&n.pc.version&&e.push("PlayCanvas "+n.pc.version),[...document.querySelectorAll("canvas")].some(r=>r.__r3f||r.parentElement?.__r3f)&&e.push("React Three Fiber");let i=n.__rlContexts||{},h=document.querySelectorAll("canvas").length;return{frameworks:e.map(r=>r.trim()),webgl:(i.webgl||0)+(i.webgl2||0),webgpu:i.webgpu||0,canvases:h,xr:!!n.__rlXR||!!navigator.xr&&e.length>0,is3D:e.length>0||(i.webgl||0)+(i.webgl2||0)+(i.webgpu||0)>0}}function tt(n={}){let e=null;n.revealSkipped&&(e=document.createElement("style"),e.textContent="*{content-visibility:visible!important}",document.head.append(e));try{return At(n)}finally{e?.remove()}}function At(n){let e=ct(),i={width:innerWidth,height:innerHeight},h=[],r=t=>h.push(t),p=[],c=[],g=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT);for(let t=g.currentNode;t&&!(p.length>=$t);t=g.nextNode()){if(!(t instanceof HTMLElement)||J.has(t.tagName)||t.closest("[data-rl-overlay]"))continue;let{text:d,rects:a}=dt(t,e);if(!d||!a.length||e.hidden(t)||e.effectiveOpacity(t)<.05||!n.revealSkipped&&t.checkVisibility&&!t.checkVisibility({contentVisibilityAuto:!0}))continue;let l=t.getBoundingClientRect();if(l.width<=2||l.height<=2)continue;let x=P(t);p.push({el:t,key:R(t),text:d,rects:a,ignore:x,pinned:e.isPinned(t)})}let f=[];p.forEach((t,d)=>t.rects.forEach(a=>f.push({i:d,r:a}))),f.sort((t,d)=>t.r.top-d.r.top);let o=new Set,s=[],u=0;for(let t=0;t<f.length;t++){let d=f[t];for(;u<t&&f[u].r.bottom<=d.r.top;)u++;for(let a=u;a<t;a++){let l=f[a];if(d.i===l.i||l.r.bottom<=d.r.top)continue;let x=p[d.i],w=p[l.i];if(x.pinned!==w.pinned||x.el.contains(w.el)||w.el.contains(x.el)||x.ignore.has("all")||x.ignore.has("text-overlap")||w.ignore.has("all")||w.ignore.has("text-overlap"))continue;let y=z(d.r,l.r),k=Math.min(I(d.r),I(l.r)),E=Math.min(d.r.bottom-d.r.top,l.r.bottom-l.r.top);if(I(y)<.25*k||y.bottom-y.top<.4*E)continue;let T=d.i<l.i?d.i+":"+l.i:l.i+":"+d.i;o.has(T)||(o.add(T),s.push({ta:x,tb:w,cut:y,share:Math.round(100*I(y)/k)}))}}for(let t of St(s)){let{ta:d,tb:a,cut:l,share:x,top:w}=t;r({rule:"text-overlap",keys:[d.key,a.key].sort(),elements:[{key:d.key,text:d.text.slice(0,60)},{key:a.key,text:a.text.slice(0,60)}],rect:l,onTop:w,measured:{overlap:x+"% of the smaller line",...w?{onTop:w.summary}:{}}})}for(let t of p){let d=t.text.split(/\s+/).filter(Boolean).length,a=ht(t.rects);if(c.length<pt&&t.text.length>=6){let l=Math.min(...t.rects.map(k=>k.left)),x=Math.max(...t.rects.map(k=>k.right)),w=Math.min(...t.rects.map(k=>k.top)),y=Math.max(...t.rects.map(k=>k.bottom));c.push({key:t.key,kind:"text",text:t.text.slice(0,60),words:d,lines:a,w:Math.round(x-l),rect:{left:l,top:w,right:x,bottom:y}})}if(!(t.ignore.has("all")||t.ignore.has("squashed-text"))&&d>=3&&a>=3&&d/a<=1.25&&t.text.length>=15){let l=Math.min(...t.rects.map(k=>k.left)),x=Math.max(...t.rects.map(k=>k.right)),w=Math.min(...t.rects.map(k=>k.top)),y=Math.max(...t.rects.map(k=>k.bottom));r({rule:"squashed-text",keys:[t.key],elements:[{key:t.key,text:t.text.slice(0,60)}],rect:{left:l,top:w,right:x,bottom:y},measured:{width:Math.round(x-l),lines:a,words:d}})}}let b=new Set;for(let t of p)for(let d=t.el;d&&d!==document.body;d=d.parentElement){let a=e.cs(d),l=a.overflowX==="hidden"||a.overflowX==="clip",x=a.overflowY==="hidden"||a.overflowY==="clip";if(!l&&!x)continue;if(b.has(d)||(b.add(d),d.clientWidth<2||d.clientHeight<2||e.hidden(d))||a.webkitLineClamp&&a.webkitLineClamp!=="none"||!(l&&d.scrollWidth>d.clientWidth+2||x&&d.scrollHeight>d.clientHeight+2))break;let y=d.getBoundingClientRect(),k={left:y.left+scrollX,top:y.top+scrollY,right:y.left+scrollX+d.clientWidth,bottom:y.top+scrollY+d.clientHeight},E=P(d);!E.has("all")&&!E.has("clipped-text")&&r({rule:"clipped-text",keys:[R(d)],elements:[{key:R(d),text:Y(d,t.text)}],rect:k,ellipsis:a.textOverflow==="ellipsis",measured:{contentWidth:d.scrollWidth,boxWidth:d.clientWidth,contentHeight:d.scrollHeight,boxHeight:d.clientHeight}});break}let m=document.documentElement.scrollWidth;if(m>i.width+1&&!P(document.body).has("page-overflow")){let t=[],d=document.body.querySelectorAll("*");for(let a of d){if(t.length>=5)break;if(!(a instanceof HTMLElement)||J.has(a.tagName)||e.hidden(a))continue;let l=a.getBoundingClientRect();l.right+scrollX<=i.width+1||l.width===0||e.clipRect(a.parentElement).right<=i.width+1||a.parentElement.getBoundingClientRect().right+scrollX>i.width+1&&a.parentElement!==document.body||t.push({key:R(a),text:Y(a,(a.textContent||"").trim())||a.tagName.toLowerCase(),right:Math.round(l.right+scrollX)})}r({rule:"page-overflow",keys:t.map(a=>a.key).sort().slice(0,1),elements:t,rect:null,measured:{pageWidth:m,viewport:i.width,by:m-i.width}})}for(let t of document.body.querySelectorAll(lt)){if(!(t instanceof HTMLElement)||t.closest("[data-rl-overlay]"))continue;let d=e.cs(t);if(d.display==="none"||t.disabled||t.closest("[aria-hidden=true],[inert],[hidden]"))continue;let a=t.getBoundingClientRect();if(a.width<4||a.height<4)continue;let l={left:a.left+scrollX,top:a.top+scrollY,right:a.right+scrollX,bottom:a.bottom+scrollY};if(I(z(l,e.clipRect(t.parentElement)))<4)continue;let x=e.effectiveOpacity(t),w=x<.1&&d.visibility==="visible"&&d.pointerEvents!=="none";if(c.length<pt+500&&c.push({key:R(t),kind:"control",text:Y(t,(t.textContent||"").trim()),visible:!w,rect:l}),!w||t.matches("input[type=checkbox],input[type=radio],input[type=file],input[type=range]")&&(t.labels?.length||t.closest("label")))continue;let y=P(t);y.has("all")||y.has("hidden-control")||r({rule:"hidden-control",keys:[R(t)],elements:[{key:R(t),text:Y(t,(t.textContent||"").trim())||t.tagName.toLowerCase()}],rect:l,measured:{opacity:+x.toFixed(2)}})}return{width:i.width,height:i.height,env:Q(),findings:h,measures:c}}function St(n){if(!n.length)return[];let e=document.createElement("style");e.textContent="*{pointer-events:auto!important}",document.head.append(e);let i=scrollX,h=scrollY,r=[];try{for(let p of n){let c=(p.cut.left+p.cut.right)/2,g=(p.cut.top+p.cut.bottom)/2,f=p.ta.pinned&&p.tb.pinned,o=c-scrollX,s=g-scrollY;!f&&(o<0||s<0||o>=innerWidth||s>=innerHeight)&&(window.scrollTo({left:Math.max(0,c-innerWidth/2),top:Math.max(0,g-innerHeight/2),behavior:"instant"}),o=c-scrollX,s=g-scrollY),f&&(o=c-i,s=g-h);let u=document.elementsFromPoint(o,s),b=a=>u.findIndex(l=>l===a||a.contains(l)),m=b(p.ta.el),t=b(p.tb.el);if(m<0&&t<0)continue;let d=m<0?p.tb.el:t<0||m<=t?p.ta.el:p.tb.el;r.push({...p,top:Rt(d)})}}finally{e.remove(),(scrollX!==i||scrollY!==h)&&window.scrollTo({left:i,top:h,behavior:"instant"})}return r}function Rt(n){let e=n;for(let p=n;p&&p!==document.body;p=p.parentElement){let c=getComputedStyle(p);if(c.position!=="static"||c.zIndex!=="auto"||c.transform!=="none"){e=p;break}}let i=getComputedStyle(e),h=[i.position!=="static"?"position: "+i.position:"",i.zIndex!=="auto"?"z-index: "+i.zIndex:"",i.transform!=="none"?"transformed":""].filter(Boolean),r=(n.textContent||"").replace(/\s+/g," ").trim().slice(0,40);return{key:R(e),text:r,position:i.position,zIndex:i.zIndex,summary:`"${r}"`+(h.length?" ("+h.join(", ")+")":" (normal flow)")}}var mt="https://github.com/prajwalsouza/ResponsiveLint/blob/main/",ut={"responsivelint-fix-overlap":{title:"Fix text drawn over other text",rules:["text-overlap"]},"responsivelint-fix-cramped-text":{title:"Fix text that is squeezed or cut off",rules:["squashed-text","clipped-text","width-outlier"]},"responsivelint-fix-overflow":{title:"Fix a page that scrolls sideways",rules:["page-overflow"]},"responsivelint-fix-controls":{title:"Fix controls that are invisible or go missing",rules:["hidden-control","disappears-in-band"]}},Lt=n=>{let e=Object.keys(ut).find(h=>ut[h].rules.includes(n))||"responsivelint-fix",i=`agents/skills/${e}/SKILL.md`;return{name:e,file:i,url:mt+i}},D={"text-overlap":{pack:"text",severity:"error",confidence:"high",title:"Text covers other text",why:"Two pieces of visible text are drawn in the same place, so neither can be read.",tries:["An element with position: absolute or fixed sits on text that wraps at this width: place it with flex or grid instead, or move it off the text. Changing z-index only swaps which text is hidden.","A box has a fixed height, so its text spills out when it wraps: remove height, or use min-height.","A negative margin or a transform pulls one element onto another: remove it at these widths.","A toast, tooltip or badge is placed on a toolbar: place it above or beside the toolbar."]},"squashed-text":{pack:"text",severity:"warning",confidence:"high",title:"Text squeezed to about one word per line",why:"The text has become so narrow that almost every word sits on its own line.",tries:["A neighbour in the same row does not wrap (white-space: nowrap, flex-shrink: 0, an auto grid column full of buttons): let it wrap with flex-wrap: wrap, or put it on its own line with grid-template-columns: 1fr.","The row keeps two columns at a width where one fits better: stack them below this width with a media or container query.","Nothing stops the text from shrinking: give it min-width: 12em (or similar)."]},"clipped-text":{pack:"text",severity:"warning",confidence:"medium",title:"Text cut off by its box",why:"A box with overflow hidden is smaller than the text inside it, so part of the text is not shown.",tries:["The box has a fixed width or height: remove it, or use min-width or min-height, so the box grows with its text.","The text is not allowed to wrap (white-space: nowrap): allow wrapping.","The cut is intended: add text-overflow: ellipsis and a title with the full text, so the finding becomes a note."]},"page-overflow":{pack:"overflow",severity:"error",confidence:"high",title:"The page scrolls sideways",why:"Something is wider than the screen, so the whole page can be dragged sideways.",tries:["The named element has a fixed width in pixels: use max-width: 100%, or a width in % or fr.","A row of controls or a long word or URL does not wrap: add flex-wrap: wrap, or overflow-wrap: anywhere for long words.","A wide table, code block or image: wrap it in a box with overflow-x: auto, or give images max-width: 100%.","Do not hide the problem with overflow-x: hidden on body or html; it cuts content off instead."]},"hidden-control":{pack:"visibility",severity:"warning",confidence:"medium",title:"A control takes space but cannot be seen",why:"A button, link or tab is laid out, clickable and focusable, but fully transparent in its resting state, so people do not know it is there.",tries:["It appears only on hover (opacity: 0 until :hover): show it at rest, perhaps quieter, because touch screens have no hover.","It should stay hidden until something happens: hide it properly with display: none, visibility: hidden or the hidden attribute until then, so it leaves the tab order too.","Keyboard users cannot find it: also show it on :focus-visible and :focus-within."]},"width-outlier":{pack:"sweep",severity:"warning",confidence:"high",title:"Breaks only in a narrow band of widths",why:"This element looks normal at the widths on both sides, but changes sharply inside this band, which is how layout bugs between breakpoints show up.",tries:["One part of the layout switches at a breakpoint before another does (a sidebar appears before the content stacks): line the two media queries up, or switch the content to a container query.","A neighbour stops wrapping inside the band and takes the width: let it wrap, or stack it below this width.","A fixed size takes over inside the band: replace it with min(), max() or clamp()."]},"disappears-in-band":{pack:"sweep",severity:"warning",confidence:"medium",title:"A control disappears in a narrow band of widths",why:"The control is visible at the widths on both sides but not inside this band.",tries:["Two media queries hand over at different widths (one hides the desktop control, the other shows the mobile one a few pixels later): use the same width for both, or one query.","max-width and min-width both use the same number, so one pixel shows neither: use max-width: 767px with min-width: 768px, or a range query.","The control is pushed out of its row and clipped: let the row wrap."]}};for(let n of Object.values(D))n.fix=n.tries[0];function Ct(n,e){let i=[...new Set(n)].sort((p,c)=>p-c),h=new Map(e.map((p,c)=>[p,c])),r=[];for(let p of i){let c=r[r.length-1];c&&h.get(p)===h.get(c[1])+1?c[1]=p:r.push([p,p])}return r}var ft=n=>{let e=[...n].sort((i,h)=>i-h);return e.length?e[Math.floor(e.length/2)]:0};function _t(n,e,i){let h=[];for(let[r,p]of n){let c=e.map(s=>p.get(s));if(c.filter(Boolean).length<5)continue;let g=c.find(Boolean).kind,f=new Array(c.length).fill(!1);for(let s=0;s<c.length;s++){let u=c[s],b=[];for(let m=1;m<=3;m++)c[s-m]&&b.push(c[s-m]),c[s+m]&&b.push(c[s+m]);if(!(b.length<3)){if(g==="text"){if(!u)continue;let m=ft(b.map(a=>a.lines)),t=ft(b.map(a=>a.words/Math.max(1,a.lines))),d=u.words/Math.max(1,u.lines);f[s]=u.words>=3&&u.lines>=Math.max(3,2*m,m+2)&&d<=.5*t&&d<=2.5}else if(g==="control"){let m=b.filter(t=>t.visible).length;f[s]=(!u||!u.visible)&&m>=b.length-1}}}let o=0;for(;o<c.length;){if(!f[o]){o++;continue}let s=o;for(;s+1<c.length&&f[s+1];)s++;let u=c.slice(0,o).some((t,d)=>t&&!f[d]),b=c.slice(s+1).some((t,d)=>t&&!f[s+1+d]),m=s-o+1<=Math.max(1,Math.floor(.35*c.length));if(u&&b&&m){let t=c[o]||c.slice(o,s+1).find(Boolean),d=c.slice(0,o).reverse().find(Boolean),a=g==="text"?"width-outlier":"disappears-in-band";h.push({rule:a,keys:[r],state:i,widths:e.slice(o,s+1),elements:[{key:r,text:(t||d)?.text||""}],rect:t?.rect||d?.rect,goodWidth:e[e.indexOf(e[o])-1],measured:g==="text"&&t?{lines:t.lines,wordsPerLine:+(t.words/t.lines).toFixed(1)}:{visible:!1},expected:g==="text"&&d?{lines:d.lines,wordsPerLine:+(d.words/Math.max(1,d.lines)).toFixed(1)}:{visible:!0}})}o=s+1}}return h}function et(n,e={}){let i=[...new Set(n.map(o=>o.width))].sort((o,s)=>o-s),h=[];for(let o of n)for(let s of o.findings)h.push({...s,state:o.state,widths:[o.width]});let r=new Map;for(let o of n)r.has(o.state.id)||r.set(o.state.id,{state:o.state,snaps:[]}),r.get(o.state.id).snaps.push(o);for(let{state:o,snaps:s}of r.values()){if(s.length<5)continue;let u=new Map;for(let m of s)for(let t of m.measures)u.has(t.key+"|"+t.kind)||u.set(t.key+"|"+t.kind,new Map),u.get(t.key+"|"+t.kind).set(m.width,t);let b=new Map([...u].map(([m,t])=>[m.split("|")[0],t]));h.push(..._t(b,s.map(m=>m.width).sort((m,t)=>m-t),o))}let p=new Map;for(let o of h){let s=o.rule+"|"+o.keys.join("+");p.has(s)||p.set(s,{...o,widths:[],states:[],instances:[]});let u=p.get(s);u.widths.push(...o.widths),u.states.some(b=>b.id===o.state.id)||u.states.push(o.state),u.instances.push({state:o.state.id,width:o.widths[0],rect:o.rect,measured:o.measured})}Ht(p);let c={error:0,warning:1,info:2},g={high:0,medium:1,low:2},f=[];for(let[o,s]of p){let u=D[s.rule];if(e.only&&!e.only.includes(u.pack)&&!e.only.includes(s.rule)||e.skip&&(e.skip.includes(u.pack)||e.skip.includes(s.rule)))continue;let b=u.severity,m=u.confidence;s.rule==="clipped-text"&&s.ellipsis&&(b="info");let t=[...new Set(s.widths)].sort((a,l)=>a-l),d=Wt(s,u);f.push({id:It(o),rule:s.rule,pack:u.pack,severity:b,confidence:m,title:u.title,elements:s.elements,widths:t,bands:Ct(t,i),everyWidth:t.length===i.length,states:s.states.map(a=>a.label),measured:s.measured,expected:s.expected,why:u.why,fix:d[0],tries:d,guide:mt+"docs/rules/"+s.rule+".md",skill:Lt(s.rule),suppress:`data-rl-ignore="${s.rule}"`,instances:s.instances.slice(0,50),goodWidth:s.goodWidth})}return e.minConfidence&&f.splice(0,f.length,...f.filter(o=>g[o.confidence]<=g[e.minConfidence])),f.sort((o,s)=>c[o.severity]-c[s.severity]||g[o.confidence]-g[s.confidence]||s.widths.length-o.widths.length),{widths:i,findings:f}}function Wt(n,e){let i=[...e.tries],h=(p,c)=>{let[g]=i.splice(p,1);i.unshift(c||g)},r=n.measured||{};if(n.rule==="text-overlap"){let p=n.onTop;p&&["absolute","fixed","sticky"].includes(p.position)?h(0,`The text on top, ${p.summary}, is taken out of the normal layout: place it with flex or grid instead, or move it so it does not sit on the text. Changing z-index only swaps which text is hidden. (${p.key})`):p&&p.position==="static"&&h(1)}else n.rule==="clipped-text"&&(n.ellipsis?h(2,"The cut is marked with an ellipsis, so it looks intended: make sure a title or tooltip gives the full text."):r.contentWidth>r.boxWidth&&!(r.contentHeight>r.boxHeight)&&h(1));return i}function Ht(n){let e=r=>r.includes(">")?r.slice(0,r.lastIndexOf(">")):r,i=new Map;for(let[r,p]of n){if(p.rule!=="text-overlap")continue;let[c,g]=p.keys;for(let[f,o]of[[c,g],[g,c]]){let s=f+"~"+e(o);i.has(s)||i.set(s,[]),i.get(s).push({id:r,shared:f,other:o})}}let h=new Set;for(let[r,p]of[...i].sort((c,g)=>g[1].length-c[1].length)){let c=p.filter(m=>!h.has(m.id)&&n.has(m.id));if(c.length<2)continue;let g=n.get(c[0].id),f=c[0].shared,o=e(c[0].other),s=g.elements.find(m=>m.key===f),u=c.map(m=>n.get(m.id).elements.find(t=>t.key===m.other)?.text).filter(Boolean),b={...g,keys:[f,o],widths:[],states:[],instances:[],elements:[s,{key:o,text:u.join(" \xB7 ").slice(0,60)}]};for(let m of c){let t=n.get(m.id);b.widths.push(...t.widths);for(let d of t.states)b.states.some(a=>a.id===d.id)||b.states.push(d);b.instances.push(...t.instances),n.delete(m.id),h.add(m.id)}n.set("text-overlap|"+f+"+"+o,b)}}function It(n){let e=2166136261;for(let i=0;i<n.length;i++)e^=n.charCodeAt(i),e=Math.imul(e,16777619);return(e>>>0).toString(36)}var X={error:"hsla(358, 75%, 59%, 1)",warning:"hsla(38, 92%, 50%, 1)",info:"hsla(220, 9%, 46%, 1)",labelText:"hsla(0, 0%, 100%, 1)",halo:"hsla(0, 0%, 100%, 0.85)"},Xt=(n,e)=>`${n.title} \xB7 ${e} px`;function wt(n,e,{width:i,rect:h}={}){let r=n.defaultView;Nt(n);let p=(e.elements||[]).map(l=>{try{return n.querySelector(l.key)}catch{return null}}),c=p[0];if(c){let l=c.getBoundingClientRect(),x=l.left<0||l.right>r.innerWidth?Math.max(0,r.scrollX+l.left-16):r.scrollX;r.scrollTo(x,Math.max(0,r.scrollY+l.top-Math.max(48,(r.innerHeight-l.height)/3)))}else h&&r.scrollTo(0,Math.max(0,h.top-r.innerHeight/3));let g=l=>{let x=l.getBoundingClientRect();return{left:x.left+r.scrollX,top:x.top+r.scrollY,right:x.right+r.scrollX,bottom:x.bottom+r.scrollY}},f=c?g(c):h;if(!f)return{found:!1,rect:null,remove:()=>{}};let o=X[e.severity]||X.error,s=n.createElement("div");s.setAttribute("data-rl-overlay","highlight"),s.style.cssText="all:initial;position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none";let u=s.attachShadow({mode:"open"}),b=(l,x)=>{let w=n.createElement("div");w.style.cssText=`position:absolute;box-sizing:border-box;left:${l.left-3}px;top:${l.top-3}px;width:${l.right-l.left+6}px;height:${l.bottom-l.top+6}px;border:2px ${x?"dashed":"solid"} ${o};border-radius:4px;box-shadow:0 0 0 2px ${X.halo}`,w.setAttribute("part",x?"other":"outline"),u.append(w)};b(f,!1),p[1]&&p[1]!==c&&b(g(p[1]),!0);let m=f.top-r.scrollY>56||f.top>56,t=Math.min(Math.max(f.left+12,12),r.scrollX+r.innerWidth-24),d=n.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("width","16"),d.setAttribute("height","10"),d.setAttribute("viewBox","0 0 16 10"),d.setAttribute("part","pointer"),d.style.cssText=`position:absolute;left:${t}px;top:${m?f.top-15:f.bottom+5}px;overflow:visible;${m?"":"transform:rotate(180deg)"}`,d.innerHTML=`<path d="M0 0 L16 0 L8 10 Z" fill="${o}"/>`,u.append(d);let a=n.createElement("div");return a.setAttribute("part","label"),a.textContent=Xt(e,i??r.innerWidth),a.style.cssText=`position:absolute;left:${Math.max(4,t-8)}px;top:${m?f.top-15:f.bottom+15}px;transform:${m?"translateY(-100%)":"none"};max-width:${Math.max(160,r.innerWidth-24)}px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:${o};color:${X.labelText};font:600 12px/1.4 system-ui,-apple-system,sans-serif;padding:3px 8px;border-radius:5px`,u.append(a),n.body.append(s),{found:!!c,rect:f,remove:()=>s.remove()}}function Nt(n){for(let e of n.querySelectorAll('[data-rl-overlay="highlight"]'))e.remove()}var L={bg:"hsla(222, 18%, 13%, 0.96)",fg:"hsla(0, 0%, 100%, 0.95)",muted:"hsla(220, 12%, 72%, 1)",line:"hsla(0, 0%, 100%, 0.14)",hover:"hsla(0, 0%, 100%, 0.08)",link:"hsla(212, 92%, 72%, 1)",shadow:"hsla(0, 0%, 0%, 0.28)"},Ot=`
2
+ :host { all: initial; }
3
+ .bar { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2147483647; box-sizing: border-box;
4
+ width: min(560px, calc(100vw - 16px)); background: ${L.bg}; color: ${L.fg}; border-radius: 12px; padding: 10px 12px;
5
+ box-shadow: 0 8px 28px ${L.shadow}; font: 13px/1.45 system-ui, -apple-system, sans-serif; }
6
+ .nav { display: flex; align-items: center; gap: 6px; }
7
+ button { all: unset; cursor: pointer; padding: 3px 10px; border-radius: 7px; border: 1px solid ${L.line}; color: ${L.fg}; font: inherit; }
8
+ button:hover:not([disabled]) { background: ${L.hover}; }
9
+ button[disabled] { opacity: .4; cursor: default; }
10
+ button.close { border-color: transparent; margin-left: auto; padding: 3px 8px; font-size: 16px; line-height: 1; }
11
+ .count { color: ${L.muted}; min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
12
+ .title { margin-top: 8px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
13
+ .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
14
+ .where, .note, .skill { color: ${L.muted}; margin-top: 2px; }
15
+ .try { margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
16
+ a { color: ${L.link}; text-decoration: none; }
17
+ a:hover { text-decoration: none; opacity: .85; }
18
+ [hidden] { display: none !important; }
19
+ `,Ft=n=>(n.bands||[]).map(([e,i])=>e===i?`${e}`:`${e}\u2013${i}`).join(", ")+" px";function gt(n,{onPrev:e,onNext:i,onClose:h}={}){let r=n.createElement("div");r.setAttribute("data-rl-overlay","bar");let p=r.attachShadow({mode:"open"});p.innerHTML=`<style>${Ot}</style><div class="bar" role="dialog" aria-label="ResponsiveLint replay">
20
+ <div class="nav"><button class="prev" type="button">\u2039 Previous</button><span class="count"></span><button class="next" type="button">Next \u203A</button>
21
+ <button class="close" type="button" aria-label="Close">\xD7</button></div>
22
+ <div class="title"><span class="dot"></span><span class="text"></span></div>
23
+ <div class="where"></div><div class="try"></div><div class="skill"></div><div class="note" hidden></div></div>`;let c=f=>p.querySelector(f);c(".prev").onclick=()=>e?.(),c(".next").onclick=()=>i?.(),c(".close").onclick=()=>h?.();let g=f=>{if(!f.target?.closest?.("input,textarea,select,[contenteditable]")){if(f.key==="ArrowRight")i?.();else if(f.key==="ArrowLeft")e?.();else if(f.key==="Escape")h?.();else return;f.preventDefault()}};return n.addEventListener("keydown",g,!0),(n.body||n.documentElement).append(r),{host:r,update({finding:f,index:o,total:s,width:u,note:b,busy:m}){c(".count").textContent=`${o+1} of ${s}`,c(".prev").disabled=m||o<=0,c(".next").disabled=m||o>=s-1,c(".dot").style.background=X[f.severity]||X.error,c(".text").textContent=f.title;let t=(f.states||[]).join(" \xB7 ");c(".where").textContent=`${Ft(f)}${t?" \xB7 "+t:""}${u?` \xB7 shown at ${u} px`:""}`,c(".try").textContent=f.tries?.[0]?"Try: "+f.tries[0]:"";let d=c(".skill");if(d.textContent="",f.skill?.url){let a=n.createElement("a");a.href=f.skill.url,a.target="_blank",a.rel="noopener",a.textContent=f.skill.name,d.append("Fix skill: ",a)}c(".note").hidden=!(b||m),c(".note").textContent=m?"Loading from the start\u2026":b||""},remove(){n.removeEventListener("keydown",g,!0),r.remove()}}}function xt(n,e,{url:i,route:h,storage:r,height:p}){let c=n.instances[0],g=e.find(m=>m.id===c?.state)||e[0],f=n.instances.filter(m=>m.state===c?.state).map(m=>m.width),o=n.bands.find(([m,t])=>f.some(d=>d>=m&&d<=t))||n.bands[0],s=(o[0]+o[1])/2,u=f.filter(m=>m>=o[0]&&m<=o[1]),b=(u.length?u:f.length?f:[Math.round(s)]).reduce((m,t)=>Math.abs(t-s)<Math.abs(m-s)?t:m);return{url:i,route:h,storage:r,width:b,height:p,startWidth:1280,state:g.id,label:g.label,actions:g.actions||[]}}var nt="responsivelint-frame",bt=document.currentScript,_=bt?bt.dataset:{};if(window.name===nt)window.__ResponsiveLintFrame={checkNow:tt};else{let n=/^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost|.+\.test)$/.test(location.hostname)||location.protocol==="file:",e=window.ResponsiveLint=Dt();if(n||"anywhere"in _){let i=async()=>{e.check();let h=_.ui==="replay";"ui"in _&&!h&&e.ui(!0),"sweep"in _&&(!h||!_.report)&&await e.sweep(),h&&e.replay()};document.readyState==="complete"?setTimeout(i,50):addEventListener("load",()=>setTimeout(i,50))}}var yt={wait:300,clickWait:300,clickTimeout:3e3,pace:0},Bt=5e3,Pt=250,F=n=>new Promise(e=>setTimeout(e,n)),Yt=(n,e=2)=>new Promise(i=>{let h=r=>r?n.requestAnimationFrame(()=>h(r-1)):i();h(e)});function vt(n={}){let e={...yt};for(let i of Object.keys(yt)){let h=n[i]??_[i];h!=null&&h!==""&&Number.isFinite(+h)&&+h>=0&&(e[i]=+h)}return e}async function K(n,e=0){try{await n.document.fonts?.ready,await Yt(n);let i=(n.document.getAnimations?.()||[]).filter(h=>h.playState==="running"&&h.effect?.getTiming?.().iterations!==1/0);await Promise.race([Promise.all(i.map(h=>h.finished.catch(()=>{}))),F(600)])}catch{}e&&await F(e)}function jt(n){let e=0,i=0,h=c=>{e=Math.max(0,e+c),i=Date.now()},r=c=>String(c||"GET").toUpperCase(),p=c=>["GET","HEAD","OPTIONS"].includes(r(c));try{let c=n.fetch;c&&(n.fetch=function(f,o){let s=o?.method||f&&typeof f=="object"&&f.method;return p(s)?(h(1),c.call(this,f,o).finally(()=>h(-1))):Promise.reject(new TypeError("ResponsiveLint replay blocks "+r(s)+" requests"))});let g=n.XMLHttpRequest?.prototype;if(g){let f=g.open,o=g.send;g.open=function(s,...u){return this.__rlMethod=s,f.call(this,s,...u)},g.send=function(...s){if(!p(this.__rlMethod)){this.abort();return}return h(1),this.addEventListener("loadend",()=>h(-1),{once:!0}),o.apply(this,s)}}}catch{}return async()=>{let c=Date.now()+Bt;for(;Date.now()<c;){if(!e&&Date.now()-i>=Pt)return;await F(40)}}}async function zt(n,e,i){let h=Date.now()+i;for(;;){let r=n.querySelector(e);if(r){let p=r.getBoundingClientRect();if(p.width&&p.height&&n.defaultView.getComputedStyle(r).visibility!=="hidden")return r}if(Date.now()>h)throw new Error(`no visible ${e} after ${i} ms`);await F(50)}}function Dt(){let n=new Set,e=new Set,i=[],h=[],r=!1,p=0,c=a=>e.forEach(l=>{try{l(a)}catch{}});function g(a){for(let l of a){if(n.has(l.id))continue;n.add(l.id),c(l);let x=l.severity==="error"?"#e5484d":l.severity==="warning"?"#d08a12":"#888";console.groupCollapsed(`%cResponsiveLint%c ${l.severity==="error"?"\u2716":"\u25B2"} ${l.rule}: ${l.title}`,"font-weight:700",`color:${x}`);for(let w of l.elements)console.log(w.text?`\u201C${w.text}\u201D`:w.key,document.querySelector(w.key)||w.key);console.log("where:",l.bands.map(([w,y])=>w===y?w:`${w}\u2013${y}`).join(", ")+" px",l.states.join(" \xB7 ")),l.measured&&console.log("measured:",l.measured,l.expected?["neighbours:",l.expected]:""),console.log("why:",l.why),console.log(`try:
24
+ `+l.tries.map((w,y)=>`${y+1}. ${w}`).join(`
25
+ `)),console.log("skill:",l.skill.name,l.skill.url),console.log("silence:",l.suppress),console.groupEnd()}}function f(){let a=tt(),l=Q();return i=et([{state:{id:"live",label:"live page"},width:a.width,findings:a.findings,measures:[]}]).findings,g(i),l.is3D&&!n.has("3d")&&(n.add("3d"),console.info("ResponsiveLint: 3D detected ("+(l.frameworks.join(", ")||"WebGL")+"). The 3D rule pack is not implemented yet.")),r&&b(),i}let o=()=>{clearTimeout(p),p=setTimeout(f,500)};addEventListener("resize",o),addEventListener("click",o,!0),new MutationObserver(a=>{a.some(l=>!(l.target instanceof Element&&l.target.closest("[data-rl-overlay]")))&&o()}).observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","hidden","aria-expanded","open"]});async function s({from:a=320,to:l=1920,step:x=48}={}){let w=document.createElement("iframe");w.name=nt,w.src=location.href,w.setAttribute("data-rl-overlay",""),w.style.cssText=`position:fixed;left:-20000px;top:0;height:${innerHeight}px;width:1280px;border:0;visibility:hidden`,document.body.append(w);try{await new Promise((E,T)=>{w.onload=E,setTimeout(()=>T(new Error("timeout")),2e4)});let y=w.contentWindow;if(!y.__ResponsiveLintFrame)throw new Error("the page does not load this script in a frame");await K(y,vt().wait);let k=[];for(let E=a;E<=l;E+=x){w.style.width=E+"px",await new Promise($=>y.requestAnimationFrame(()=>y.requestAnimationFrame(()=>setTimeout($,120))));let T=y.__ResponsiveLintFrame.checkNow();k.push({state:{id:"sweep",label:"width sweep"},width:E,findings:T.findings,measures:T.measures})}return h=et(k).findings,g(h),r&&b(),h}catch(y){return console.info("ResponsiveLint: the width sweep could not run ("+y.message+"). Use the command line, npx responsivelint, for a full sweep."),[]}finally{w.remove()}}let u=null;function b(){if(u?.remove(),!r)return;u=document.createElement("div"),u.setAttribute("data-rl-overlay",""),u.style.cssText="position:absolute;left:0;top:0;width:0;height:0;z-index:2147483646;pointer-events:none";let a=[...i,...h.filter(w=>!i.some(y=>y.id===w.id))];for(let w of i)for(let y of w.instances){let k=y.rect;if(!k)continue;let E=document.createElement("div");E.style.cssText=`position:absolute;left:${k.left}px;top:${k.top}px;width:${k.right-k.left}px;height:${k.bottom-k.top}px;outline:2px solid ${w.severity==="error"?"#e5484d":"#d08a12"};outline-offset:1px;border-radius:2px`,E.title=w.title,u.append(E)}let l=document.createElement("div");l.style.cssText="position:fixed;right:12px;bottom:12px;max-width:360px;max-height:50vh;overflow:auto;pointer-events:auto;background:hsla(0,0%,100%,.97);color:#1d1f24;border-radius:10px;box-shadow:0 6px 24px hsla(0,0%,0%,.18);font:12px/1.45 system-ui,sans-serif;padding:10px 12px",l.innerHTML=`<div style="display:flex;align-items:center;gap:8px;margin-bottom:6px"><b style="margin-right:auto">ResponsiveLint \xB7 ${a.length} finding${a.length===1?"":"s"}</b>${a.length?'<button type="button" data-act="replay" style="border:1px solid hsla(220,15%,85%,1);border-radius:6px;background:none;cursor:pointer;font:inherit;padding:1px 8px">Replay</button>':""}<button type="button" data-act="close" style="border:0;background:none;cursor:pointer;font:inherit">\xD7</button></div>`,l.querySelector("[data-act=close]").onclick=()=>api.ui(!1);let x=l.querySelector("[data-act=replay]");x&&(x.onclick=()=>api.replay(a));for(let w of a){let y=document.createElement("div");y.style.cssText="padding:5px 0;border-top:1px solid hsla(220,15%,90%,1);cursor:pointer";let k=w.bands.map(([T,$])=>T===$?T:`${T}\u2013${$}`).join(", ")+" px",E=T=>String(T).replace(/[&<>"]/g,$=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[$]);y.innerHTML=`<span style="color:${w.severity==="error"?"#e5484d":"#b37400"}">${w.severity==="error"?"\u2716":"\u25B2"}</span> ${E(w.title)}<br><span style="color:#6b7280">${E((w.elements[0]?.text||w.elements[0]?.key||"").slice(0,50))} \xB7 ${k}</span><br><span style="color:#374151">Try: ${E(w.tries[0])}</span> <a href="${E(w.skill.url)}" target="_blank" rel="noopener" style="color:hsla(220,70%,45%,1);text-decoration:none">${E(w.skill.name)}</a>`,y.onclick=()=>document.querySelector(w.elements[0]?.key)?.scrollIntoView({block:"center",behavior:"smooth"}),l.append(y)}u.append(l),m&&(u.style.display="none"),document.body.append(u)}let m=null;async function t(a){let l=await fetch(a,{cache:"no-store"});if(!l.ok)throw new Error(`${a}: ${l.status}`);return(await l.json()).findings||[]}async function d(a,l={}){if(!a)try{a=_.report?await t(_.report):[...i,...h.filter(v=>!i.some(M=>M.id===v.id))]}catch(v){return console.info("ResponsiveLint: could not load the report ("+v.message+")."),null}if(!a.length)return console.info("ResponsiveLint: nothing to replay."),null;m?.close(),u&&(u.style.display="none");let x=vt(l),w=a.map(v=>({finding:v,recipe:v.replay||xt(v,[{id:v.instances?.[0]?.state||"live",label:"live page",actions:[]}],{url:location.href,route:null,storage:{},height:innerHeight})})),y=new Map,k=(v,M)=>{try{y.has(v)||y.set(v,localStorage.getItem(v)),localStorage.setItem(v,M)}catch{}},E=-1,T=null,$=0,ot=0,V=!1,it=async()=>{let v=ot+x.pace-Date.now();v>0&&await F(v),ot=Date.now()},N=document.createElement("div");N.setAttribute("data-rl-overlay","replay"),N.style.cssText="position:fixed;inset:0;z-index:2147483645;background:hsla(222,18%,10%,0.55)";let W=document.createElement("div");W.style.cssText="position:absolute;left:0;top:0;transform-origin:0 0;box-shadow:0 8px 32px hsla(0,0%,0%,0.35);background:hsla(0,0%,100%,1)",N.append(W),document.body.append(N);let G=gt(document,{onPrev:()=>j(E-1),onNext:()=>j(E+1),onClose:()=>rt()}),kt=204,U=12,st=(v,M)=>{let S=Math.min(1,(innerWidth-2*U)/v,(innerHeight-kt-U)/M);T.style.width=v+"px",T.style.height=M+"px",W.style.width=v+"px",W.style.height=M+"px",W.style.transform=`translate(${Math.round((innerWidth-v*S)/2)}px, ${U}px) scale(${S})`,W.dataset.scale=S.toFixed(3)};function Tt(v){let M=new URL(v.url,location.href);return M.origin===location.origin?M.href:location.origin+M.pathname+M.search+M.hash}async function j(v){if(V||v<0||v>=w.length)return null;let M=++$;E=v;let{finding:S,recipe:A}=w[v],at=A.height||innerHeight;G.update({finding:S,index:v,total:w.length,width:A.width,busy:!0}),T?.remove();for(let[C,B]of Object.entries(A.storage||{}))k(C,B);if(await it(),M!==$)return null;T=document.createElement("iframe"),T.name=nt,T.setAttribute("data-rl-overlay","replay-frame"),T.title="ResponsiveLint replay",T.style.cssText="display:block;border:0;background:hsla(0,0%,100%,1)",W.append(T),st(A.startWidth||1280,at);let O="";try{if(await new Promise((H,Z)=>{T.onload=H,setTimeout(()=>Z(new Error("the page took over 20 s to load")),2e4),T.src=Tt(A)}),M!==$)return null;let C=T.contentWindow,B=T.contentDocument;if(!B)throw new Error("the frame is not on the same site");let Et=jt(C);await K(C,x.wait);for(let H of A.actions||[]){let Z=await zt(B,H.click,x.clickTimeout);if(M!==$)return null;await it(),Z.click(),await Et(),await K(C,150),x.clickWait&&await F(x.clickWait)}if(st(A.width,at),await K(C),M!==$)return null;let Mt=(S.instances||[]).find(H=>H.width===A.width&&H.state===A.state&&H.rect);wt(B,S,{width:A.width,rect:Mt?.rect}).found||(O="The element is not on the page at this width."),!(A.actions||[]).length&&!S.replay&&(O=O||"Shown in the starting state: clicks made on the live page are not recorded.")}catch(C){O="Could not repeat the steps: "+C.message}return M!==$?null:(G.update({finding:S,index:v,total:w.length,width:A.width,note:O}),N.dataset.step=String(v),{index:v,note:O,frame:T})}function rt(){if(!V){V=!0,$++,G.remove(),N.remove();for(let[v,M]of y)try{M==null?localStorage.removeItem(v):localStorage.setItem(v,M)}catch{}m===q&&(m=null,b())}}let q={go:j,close:rt,get index(){return E},get frame(){return T},steps:w.map(v=>v.recipe),done:null};return m=q,q.done=j(l.start||0),await q.done,q}return{check:f,sweep:s,replay:d,ui(a=!0){return r=!!a,b(),r},on(a,l){return a==="finding"&&e.add(l),()=>e.delete(l)},get findings(){return[...i,...h]},rules:D}}})();
@@ -0,0 +1,21 @@
1
+ # clipped-text: Text cut off by its box
2
+
3
+ ## What it finds
4
+
5
+ A box with `overflow: hidden` or `clip` is smaller than its content and holds text, so part of the text is never shown. Boxes with `text-overflow: ellipsis` are reported as notes, because the cut is visible to the reader, and line clamping is treated as deliberate.
6
+
7
+ ## Common causes
8
+
9
+ A fixed `width` or `height` on a label, badge or button; `white-space: nowrap` inside a narrow box.
10
+
11
+ ## How to fix it
12
+
13
+ Let the box grow with its content, allow wrapping, or, if the cut is intended, add `text-overflow: ellipsis` and put the full text in a `title` or an accessible name.
14
+
15
+ ## Fix it with an agent
16
+
17
+ Load the [`responsivelint-fix-cramped-text`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
18
+
19
+ ## When it is intended
20
+
21
+ Add `data-rl-ignore="clipped-text"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
@@ -0,0 +1,21 @@
1
+ # disappears-in-band: A control disappears in a narrow band of widths
2
+
3
+ ## What it finds
4
+
5
+ A control is visible at the widths on both sides of a band but missing or invisible inside it.
6
+
7
+ ## Common causes
8
+
9
+ Two media queries that hand over at different widths, for example a mobile button hidden from 760 px while its desktop replacement appears only from 840 px.
10
+
11
+ ## How to fix it
12
+
13
+ Align the queries so that one layout's control appears exactly where the other's disappears, or use a single query for both.
14
+
15
+ ## Fix it with an agent
16
+
17
+ Load the [`responsivelint-fix-controls`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-controls/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
18
+
19
+ ## When it is intended
20
+
21
+ Add `data-rl-ignore="disappears-in-band"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
@@ -0,0 +1,21 @@
1
+ # hidden-control: A control takes space but cannot be seen
2
+
3
+ ## What it finds
4
+
5
+ A button, link, tab or other focusable control is laid out and can be clicked or focused, but is fully transparent (`opacity` below 0.1) in its resting state. Controls hidden with `visibility: hidden` or `pointer-events: none` are not reported, because they cannot be used either. A native checkbox or radio hidden behind a styled label is a common deliberate pattern and is also skipped.
6
+
7
+ ## Common causes
8
+
9
+ A control that is meant to appear on hover (`opacity: 0` until `:hover`), which leaves touch and keyboard users with an invisible control.
10
+
11
+ ## How to fix it
12
+
13
+ Show the control at rest. If it should appear only on hover, take it out of the layout and the tab order until then (`visibility: hidden`), and make sure touch and keyboard users have another way to reach it.
14
+
15
+ ## Fix it with an agent
16
+
17
+ Load the [`responsivelint-fix-controls`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-controls/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
18
+
19
+ ## When it is intended
20
+
21
+ Add `data-rl-ignore="hidden-control"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
@@ -0,0 +1,21 @@
1
+ # page-overflow: The page scrolls sideways
2
+
3
+ ## What it finds
4
+
5
+ The document is wider than the viewport, so the whole page can be dragged sideways. The finding names the outermost elements that stick out past the right edge and are not inside a scrolling or clipping container.
6
+
7
+ ## Common causes
8
+
9
+ A fixed `width` in pixels, a table or code block without a scrolling wrapper, a row of controls with `white-space: nowrap`, an image without `max-width: 100%`.
10
+
11
+ ## How to fix it
12
+
13
+ Fix the named element: use `max-width: 100%`, let its content wrap, or wrap wide tables and code in a container with `overflow-x: auto`. Do not hide the problem with `overflow-x: hidden` on `body`, which also hides the content.
14
+
15
+ ## Fix it with an agent
16
+
17
+ Load the [`responsivelint-fix-overflow`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overflow/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
18
+
19
+ ## When it is intended
20
+
21
+ Add `data-rl-ignore="page-overflow"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
@@ -0,0 +1,21 @@
1
+ # squashed-text: Text squeezed to about one word per line
2
+
3
+ ## What it finds
4
+
5
+ A text block of at least three words that wraps onto about one line per word. A neighbour has taken almost all of the row's width.
6
+
7
+ ## Common causes
8
+
9
+ A grid row with `minmax(0, 1fr) auto` where the `auto` column holds controls that do not wrap; a flex row where a sibling has `flex-shrink: 0` or `white-space: nowrap`.
10
+
11
+ ## How to fix it
12
+
13
+ Let the wide neighbour wrap onto its own line: switch the row to `grid-template-columns: 1fr` when the controls are many, or add `flex-wrap: wrap`. Giving the text a `min-width` (for example `12em`) also stops the squeeze.
14
+
15
+ ## Fix it with an agent
16
+
17
+ Load the [`responsivelint-fix-cramped-text`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
18
+
19
+ ## When it is intended
20
+
21
+ Add `data-rl-ignore="squashed-text"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
@@ -0,0 +1,21 @@
1
+ # text-overlap: Text covers other text
2
+
3
+ ## What it finds
4
+
5
+ Two pieces of visible text are drawn in the same place. ResponsiveLint reads the line boxes of each element's own text, cuts them to what their scrolling or clipping ancestors let show, and reports two elements whose lines cover a quarter or more of the smaller one. It ignores an element inside the other, and a pinned (fixed or sticky) element over scrolling content, because that depends on the scroll position rather than the layout.
6
+
7
+ ## Common causes
8
+
9
+ An absolutely positioned element placed over text that wraps at narrow widths; a fixed height that stops a box from growing when its text wraps; a toast or tooltip placed over a toolbar.
10
+
11
+ ## How to fix it
12
+
13
+ Let the content take its own space. Replace `position: absolute` with flex or grid placement, remove the fixed `height`, or move the overlay so it does not sit on the text. For a temporary message, place it above the toolbar rather than on it.
14
+
15
+ ## Fix it with an agent
16
+
17
+ Load the [`responsivelint-fix-overlap`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overlap/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
18
+
19
+ ## When it is intended
20
+
21
+ Add `data-rl-ignore="text-overlap"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
@@ -0,0 +1,21 @@
1
+ # width-outlier: Breaks only in a narrow band of widths
2
+
3
+ ## What it finds
4
+
5
+ The self-comparison. ResponsiveLint measures each text block at every width of the sweep and compares it with the same block at the three widths on each side. A width is reported when the block has at least twice as many lines as its neighbours, at most half their words per line and no more than two and a half words per line, and when normal widths exist on both sides of the band. A designed breakpoint changes many elements and stays changed, so it is not reported.
6
+
7
+ ## Common causes
8
+
9
+ A media query that switches one part of a layout before another; a sidebar that appears at a breakpoint and narrows the content column before the content layout adapts.
10
+
11
+ ## How to fix it
12
+
13
+ Open the page at a width inside the band and at a width just outside it. Look for the neighbour that takes the width (often controls that stop wrapping, or a column that appears) and let it wrap or move below.
14
+
15
+ ## Fix it with an agent
16
+
17
+ Load the [`responsivelint-fix-cramped-text`](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md) skill. Each finding also lists the usual causes in `tries`, most likely first.
18
+
19
+ ## When it is intended
20
+
21
+ Add `data-rl-ignore="width-outlier"` to the element or a container to stop this rule there. Use `data-rl-ignore` without a value to stop every rule. Prefer fixing the layout: an ignored finding is still a problem for readers.
package/llms.txt ADDED
@@ -0,0 +1,49 @@
1
+ # ResponsiveLint
2
+
3
+ > ResponsiveLint opens a web page in Chromium, finds layouts reachable in one click and checks a range of widths for each layout. It compares elements with themselves at nearby widths to find problems that appear only in a narrow range.
4
+
5
+ - [README](https://github.com/prajwalsouza/ResponsiveLint#readme) covers setup, command options, browser use and CI.
6
+ - [Run a check](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint/SKILL.md) explains how to run the command and read findings.
7
+ - [Fix findings](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix/SKILL.md) explains how to work through a report and which fix skill to load.
8
+ - [Fix overlapping text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overlap/SKILL.md): text-overlap.
9
+ - [Fix squeezed or cut-off text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-cramped-text/SKILL.md): squashed-text, clipped-text, width-outlier.
10
+ - [Fix sideways scrolling](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-overflow/SKILL.md): page-overflow.
11
+ - [Fix invisible or missing controls](https://github.com/prajwalsouza/ResponsiveLint/blob/main/agents/skills/responsivelint-fix-controls/SKILL.md): hidden-control, disappears-in-band.
12
+
13
+ ## Run a check
14
+
15
+ - Use Node.js 20 or newer. Install Chromium with `npx playwright install chromium` if the command cannot find it. For ResponsiveLint 0.2.0 run via `npx` alone, use `npx --yes --package=playwright@1.59.1 playwright install chromium` to match its browser version.
16
+ - Start the site's dev server and run `npx responsivelint http://localhost:5173 --json report.json`.
17
+ - A built site folder also works, for example `npx responsivelint ./dist --html report.html`.
18
+ - Normal mode checks 320 to 1920 px in 48 px steps and up to eight extra states. Aggressive mode uses 24 px steps and up to 20 extra states. Quick mode checks four widths and the starting state only. Set `--step 1` to check every whole-pixel width in the selected range.
19
+ - Use `--route '#/settings'` to start from a hash route, `--only text` to run text rules or `--states 0` to skip click exploration. Repeat `--storage key=value` to set multiple localStorage values.
20
+ - Exit code `0` means no findings met the failure threshold. Code `1` means the run found errors, or warnings under `--strict`. Code `2` means the command failed or received an unknown option.
21
+ - For an in-page check, load `dist/responsivelint.js` from the npm package. The README has the script tag, `data-ui`, `data-sweep`, `data-anywhere` and `window.ResponsiveLint` examples.
22
+ - From Node, use `import {check} from 'responsivelint'; const report = await check(url)`.
23
+ - For slow apps, `--click-wait 2000` waits longer after each click and `--pace 1000` keeps page loads and clicks at least a second apart. `--wait` pauses after load and `--click-timeout` sets how long to wait for a control. The script tag takes `data-wait`, `data-click-wait`, `data-click-timeout` and `data-pace`.
24
+
25
+ ## Replay a finding
26
+
27
+ - `npx responsivelint <url> --replay` checks, then steps through the findings in a visible browser. `npx responsivelint replay report.json [base-url]` replays a saved report.
28
+ - In the page, `data-ui="replay"` (with `data-report="report.json"` for a command-line report) or `await ResponsiveLint.replay(findings)` shows each finding in a frame at its width.
29
+ - Each step loads the page fresh at `replay.startWidth`, sets `replay.storage`, repeats the clicks in `replay.actions`, sets `replay.width` and outlines the element with a label.
30
+
31
+ ## Read and fix findings
32
+
33
+ The report includes `widths`, `states` (each with the clicks that reach it in `actions`), `timing` and `findings`. Each finding gives `rule`, `severity`, `confidence`, `elements` (selector in `key` and visible `text`), `bands` in pixels, `states`, `measured`, `why`, `tries` (the usual causes and fixes, most likely first), `skill` (the fix skill to load: `name`, `file`, `url`), `guide` and `replay` (`url`, `route`, `storage`, `startWidth`, `width`, `height`, `state`, `actions`). Sweep findings may include nearby measurements in `expected`.
34
+
35
+ Reproduce it from `replay`: load `url` at `startWidth`, apply `storage`, click each selector in `actions`, set the width to `width` and inspect the named element. Load the skill named in `skill`, check the causes in `tries` in order, fix the layout and run the check again. For an intentional layout, use `data-rl-ignore="rule-name"`.
36
+
37
+ - [text-overlap](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/text-overlap.md) finds visible text drawn over other text.
38
+ - [squashed-text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/squashed-text.md) finds text with about one word per line.
39
+ - [clipped-text](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/clipped-text.md) finds text partly hidden by its box.
40
+ - [page-overflow](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/page-overflow.md) names the element that makes the page scroll sideways.
41
+ - [hidden-control](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/hidden-control.md) finds controls that are fully transparent at rest.
42
+ - [width-outlier](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/width-outlier.md) finds elements that break only in a narrow range of widths.
43
+ - [disappears-in-band](https://github.com/prajwalsouza/ResponsiveLint/blob/main/docs/rules/disappears-in-band.md) finds controls missing in a narrow range of widths.
44
+
45
+ ## Scope and safety
46
+
47
+ The command accepts local and test hosts by default. `--allow-remote` allows another host. The runner blocks POST, PUT, PATCH and DELETE requests and navigation to other sites. It dismisses dialogs, avoids typing and skips form submit controls and names that suggest actions such as paying or deleting. Use `data-rl-never` on controls it should skip.
48
+
49
+ State discovery explores one click at a time from the starting state. It skips hover-only states. The rules measure the layout the browser renders and report when a 3D scene is detected. They do not check the layout inside that scene.
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "responsivelint",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Layout linter that checks every width and every state of a web UI against itself: overlapping text, overflow, squashed labels, hidden controls.",
5
+ "author": "Prajwal DSouza",
6
+ "license": "MIT",
7
+ "repository": {"type": "git", "url": "git+https://github.com/prajwalsouza/ResponsiveLint.git"},
8
+ "homepage": "https://github.com/prajwalsouza/ResponsiveLint#readme",
9
+ "bugs": {"url": "https://github.com/prajwalsouza/ResponsiveLint/issues"},
10
+ "keywords": [
11
+ "responsive", "layout", "lint", "linter", "overflow", "overlap", "breakpoints", "viewport",
12
+ "playwright", "accessibility", "testing", "ci"
13
+ ],
14
+ "type": "module",
15
+ "engines": {
16
+ "node": ">=20"
17
+ },
18
+ "bin": {
19
+ "responsivelint": "bin/responsivelint.mjs"
20
+ },
21
+ "exports": {
22
+ ".": "./src/index.js",
23
+ "./core": "./src/core/index.js"
24
+ },
25
+ "files": [
26
+ "bin",
27
+ "src",
28
+ "dist",
29
+ "docs",
30
+ "agents",
31
+ "llms.txt"
32
+ ],
33
+ "scripts": {
34
+ "build": "node scripts/build-browser.mjs",
35
+ "prepublishOnly": "npm run build",
36
+ "test": "npm run build && node --test test/*.test.js",
37
+ "lint:fixtures": "node bin/responsivelint.mjs fixtures/planted --json .responsivelint/planted.json"
38
+ },
39
+ "dependencies": {
40
+ "playwright": "1.59.1"
41
+ },
42
+ "devDependencies": {
43
+ "esbuild": "0.28.2"
44
+ }
45
+ }