@domphy/doctor 0.18.1 → 0.18.2
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/dist/doctor.global.js +2 -2
- package/dist/doctor.global.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +16 -15
package/dist/doctor.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var Domphy=(()=>{var E=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var s in t)E(e,s,{get:t[s],enumerable:!0})},J=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Y(t))!Z.call(e,n)&&n!==s&&E(e,n,{get:()=>t[n],enumerable:!(i=K(t,n))||i.enumerable});return e};var X=e=>J(E({},"__esModule",{value:!0}),e);var pt={};j(pt,{doctor:()=>R});var R={};j(R,{diagnose:()=>C,fix:()=>V,format:()=>W,validate:()=>x});var Q=e=>{let t=s=>s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;return e.map(t)};var A=e=>{let t=parseInt(e.slice(1,3),16)/255,s=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255;return Q([t,s,i])};var I=e=>{let[t,s,i]=e,n=.4124564*t+.3575761*s+.1804375*i,r=.2126729*t+.7151522*s+.072175*i,l=.0193339*t+.119192*s+.9503041*i,c=.95047,u=1,f=1.08883,m=g=>g>.008856?Math.cbrt(g):7.787*g+16/116,w=m(n/c),p=m(r/u),b=m(l/f);return[116*p-16,500*(w-p),200*(p-b)]};var B=e=>{let[t,s,i]=e,n=Math.sqrt(s*s+i*i);if(n<1e-4)return[t,0,0];let r=(Math.atan2(i,s)*180/Math.PI+360)%360;return r>=359.9999&&(r=0),[t,n,r]};var P=e=>{let t=e.match(/\d+(\.\d+)?/g);if(!t||t.length<3)throw new Error("Invalid CSS rgb()");let s=i=>{let n=i/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)};return[s(Number(t[0])),s(Number(t[1])),s(Number(t[2]))]};var U=["a","abbr","address","article","aside","audio","b","base","blockquote","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","slot","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","bdi","bdo","math","menu","search","area","embed","hr","animate","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","prefetch","radialGradient","rect","set","solidColor","stop","svg","switch","symbol","tbreak","text","textPath","tspan","use","view"];var F=["svg","circle","path","rect","ellipse","line","polyline","polygon","g","defs","use","symbol","linearGradient","radialGradient","stop","clipPath","mask","filter","text","tspan","textPath","image","pattern","marker","animate","animateTransform","animateMotion","feGaussianBlur","feComposite","feColorMatrix","feMerge","feMergeNode","feOffset","feFlood","feBlend","foreignObject"],z=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"];var tt=["onAbort","onAuxClick","onBeforeMatch","onBeforeToggle","onBlur","onCancel","onCanPlay","onCanPlayThrough","onChange","onClick","onClose","onContextLost","onContextMenu","onContextRestored","onCopy","onCueChange","onCut","onDblClick","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDragStart","onDrop","onDurationChange","onEmptied","onEnded","onError","onFocus","onFormData","onInput","onInvalid","onKeyDown","onKeyPress","onKeyUp","onLoad","onLoadedData","onLoadedMetadata","onLoadStart","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onPaste","onPause","onPlay","onPlaying","onProgress","onRateChange","onReset","onResize","onScroll","onScrollEnd","onSecurityPolicyViolation","onSeeked","onSeeking","onSelect","onSlotChange","onStalled","onSubmit","onSuspend","onTimeUpdate","onToggle","onVolumeChange","onWaiting","onWheel","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onGotPointerCapture","onLostPointerCapture","onCompositionStart","onCompositionUpdate","onCompositionEnd","onTransitionEnd","onTransitionStart","onAnimationStart","onAnimationEnd","onAnimationIteration","onFullscreenChange","onFullscreenError","onFocusIn","onFocusOut"],bt=tt.reduce((e,t)=>{let s=t.slice(2).toLowerCase();return e[s]=t,e},{});var vt=typeof process!="undefined"&&process.env!=null&&process.env.NODE_ENV!=="production";var et=new Set([...U,...F]),k=new Set(z);function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){for(let t in e)if(et.has(t))return t}var st=new Set(["$","style","_key","_portal","_context","_metadata","_doctorDisable"]),it=new Set(["fontSize","lineHeight","fontWeight","letterSpacing","fontFamily","textDecoration"]),nt=new Set(["color","backgroundColor","background","borderColor","border","outlineColor","outline","fill","stroke"]),rt=new Set(["color","fill","stroke","backgroundColor","outlineColor","borderColor","caretColor","accentColor","columnRuleColor","textDecorationColor"]),ot=new Set(["transparent","currentcolor","inherit","initial","unset","none","auto","revert","revert-layer",""]),H=/#[0-9a-fA-F]{3,8}\b|\b(?:rgba?|hsla?)\s*\(/,at=new Set(["margin","marginTop","marginRight","marginBottom","marginLeft","marginInline","marginBlock","marginInlineStart","marginInlineEnd","marginBlockStart","marginBlockEnd","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingInline","paddingBlock","paddingInlineStart","paddingInlineEnd","paddingBlockStart","paddingBlockEnd","gap","rowGap","columnGap"]),lt=/^(\d+(?:\.\d+)?)(rem|em|px)$/;function M(e){let t=e.match(/^(increase|decrease|shift)-(\d+)$/);return t?{family:t[1],n:parseInt(t[2],10)}:null}function ht(e){if(e==="inherit"||e==="base"||/^-?\d+$/.test(e))return!0;let t=M(e);return t?t.n<=17:!1}function ut(e){try{let t=e.trim(),s;if(t.startsWith("#")){let r=t;if(r.length===9&&(r=r.slice(0,7)),r.length===5&&(r=r.slice(0,4)),r.length===4&&(r=`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`),r.length!==7)return null;s=A(r)}else if(/^rgba?\s*\(/.test(t))s=P(t);else return null;let i=I(s),n=B(i);return[n[0],n[1],n[2]]}catch(t){return null}}var ct=/#[0-9a-fA-F]{3,8}\b|rgba?\s*\([^)]*\)/;function ft(e){let t=ct.exec(e);return t?t[0]:null}function dt(e){let[t,s,i]=e,n=Math.round((t-50)/10),r=Math.max(-9,Math.min(9,n)),l;Math.abs(r)<=1?l='"base"':r<0?l=`"decrease-${Math.abs(r)}"`:l=`"increase-${r}"`;let c;return s<12?c="neutral":i<30||i>=330?c="error":i<75?c="warning":i<165?c="success":(i<265,c="primary"),`(l) => themeColor(l, ${l}, "${c}") [perceptual LCH L=${Math.round(t)} C=${Math.round(s)} h=${Math.round(i)}\xB0]`}function mt(e,t){let s=lt.exec(t);if(!s)return null;let i=parseFloat(s[1]),n=s[2],r;return n==="rem"||n==="em"?r=Math.round(i*4):r=Math.round(i/4),r<=0?null:`${e}: themeSpacing(${r}) \u2014 themeSpacing(n)=n/4em, so ${r}/4=${r/4}em \u2248 ${t} at default density`}function q(e,t,s,i,n){if(e===!0){for(let r of s)r.path!==i&&n.push(r);return}if(e!=null&&e!==!1){let r=new Set(Array.isArray(e)?e:[String(e)]);for(let l of t)r.has(l.rule)||n.push(l);for(let l of s)l.path===i&&r.has(l.rule)||n.push(l);return}n.push(...t),n.push(...s)}function C(e,t={}){let s=[];if(S(e,"",s,!1,t),t.only!==void 0){if(t.only.length===0)return[];let i=new Set(t.only);return s.filter(n=>i.has(n.rule))}if(t.exclude&&t.exclude.length>0){let i=new Set(t.exclude);return s.filter(n=>!i.has(n.rule))}return s}function S(e,t,s,i,n){var O,N,D;let r=n.runReactive!==!1;if(typeof e=="function"){if(!r)return;let o;try{o=e(()=>{})}catch(h){return}S(o,t,s,!0,n);return}if(Array.isArray(e)){let o=e.filter(a=>y(a)&&_(a));i&&(o.length>1&&o.some(a=>a._key===void 0)&&s.push({rule:"missing-key",severity:"warning",category:"key",path:t||"(list)",message:"Dynamic list child without `_key` \u2014 reordered/keyed lists need a stable `_key` for correct reconcile.",hint:"Add `_key: <stable id>` to each item produced by the reactive function."}),o.length>1&&o.every((a,d)=>a._key===d)&&s.push({rule:"unstable-key",severity:"warning",category:"key",path:t||"(list)",message:"Dynamic list `_key` values are the array index (0, 1, 2, \u2026) \u2014 index keys are unstable across reorders/inserts.",hint:"Key by a stable identity from the data (e.g. `_key: item.id`), not the loop index."}));let h=new Map;for(let a of o){let d=a._key;if(d==null)continue;let v=`${typeof d}:${String(d)}`;h.set(v,((O=h.get(v))!=null?O:0)+1)}for(let[a,d]of h)if(d>1){let v=a.slice(a.indexOf(":")+1);s.push({rule:"duplicate-key",severity:"error",category:"key",path:t||"(list)",message:`Duplicate \`_key\` "${v}" among ${d} siblings \u2014 keys must be unique within a list.`,hint:"Give each sibling a distinct stable `_key` (e.g. a record id, not a constant)."})}e.forEach((a,d)=>{S(a,`${t}[${d}]`,s,!1,n)});return}if(!y(e))return;let l=e,c=_(l),u=c?t?`${t} > ${c}`:c:t||"(root)",f=[];if(!c){let o=Object.keys(l).filter(h=>!st.has(h)&&!h.startsWith("_on")&&!h.startsWith("on")&&!h.startsWith("data")&&!h.startsWith("aria"));o.length===1&&f.push({rule:"unknown-tag",severity:"warning",category:"structure",path:u,message:`"${o[0]}" is not a known HTML/SVG tag \u2014 likely a typo.`,hint:"An element's first key must be a valid tag (div, button, span, \u2026)."}),q(l._doctorDisable,f,[],u,s);return}let m=l[c];if(k.has(c)&&m!==null&&m!==void 0&&f.push({rule:"void-content",severity:"error",category:"structure",path:u,message:`Void tag "${c}" must have null content (got ${Array.isArray(m)?"array":typeof m}).`,hint:`Write { ${c}: null, \u2026 } and put attributes as sibling keys.`}),y(l.style)){let o=l.style;for(let h in o){let a=o[h];if(it.has(h)&&typeof a!="function"&&f.push({rule:"inline-typography",severity:"warning",category:"typography",path:u,message:`Inline \`${h}\` \u2014 avoid inline typography styles.`,hint:"Use a typography patch (paragraph()/heading()/small()/strong()/\u2026) via $ so the theme owns the type scale."}),nt.has(h)&&typeof a=="string"&&H.test(a)){let d=(N=ft(a))!=null?N:a,v=ut(d),G=v?dt(v):"(l) => themeColor(l, tone, colorName)";f.push({rule:"raw-theme-value",severity:"info",category:"theme",path:u,message:`Inline \`${h}\` uses a literal color (${a}).`,hint:`Prefer a theme token \u2014 ${G} \u2014 so theming and dark mode apply.`})}if(rt.has(h)&&typeof a=="string"&&!H.test(a)&&!a.includes("(")&&!a.startsWith("--")&&!ot.has(a.trim().toLowerCase())&&f.push({rule:"raw-theme-value",severity:"info",category:"theme",path:u,message:`Inline \`${h}\` uses a CSS named color ("${a}").`,hint:`CSS named colors like "${a}" bypass theming and dark mode. Prefer (l) => themeColor(l, tone, colorName) \u2014 so the theme context applies.`}),at.has(h)&&typeof a=="string"){let d=mt(h,a);d&&f.push({rule:"raw-spacing-value",severity:"info",category:"theme",path:u,message:`Inline \`${h}: "${a}"\` uses a literal spacing value.`,hint:`Prefer themeSpacing() for theme density: ${d}`})}}}let w=y(l.style)?l.style.backgroundColor:void 0;if(typeof w=="function"&&r){let o;try{o=w(()=>{})}catch(h){}if(typeof o=="string"){let h=o.match(/var\(--[\w-]+-(\d+)\)$/);h&&parseInt(h[1],10)>0&&f.push({rule:"tone-background-inherit",severity:"warning",category:"theme",path:u,message:`\`style.backgroundColor\` uses a fixed tone (resolves to "${o}" at base context) instead of "inherit".`,hint:'backgroundColor should always be (l) => themeColor(l, "inherit"). To shift the surface tone, set dataTone on the container \u2014 it applies to all children uniformly.'})}}let p=l.dataTone;if(typeof p=="string")if(!ht(p))f.push({rule:"unknown-tone",severity:"warning",category:"data-attr",path:u,message:`\`dataTone\` "${p}" is not a valid tone.`,hint:'Use "inherit", "base", a number, or "shift-N"/"increase-N"/"decrease-N" with N \u2264 17 (the ramp has 18 steps). Words like "surface"/"text" are not tones.'});else{let o=M(p);(o==null?void 0:o.family)==="shift"&&o.n>=4&&o.n<=13&&f.push({rule:"middle-surface-anchor",severity:"warning",category:"data-attr",path:u,message:`\`dataTone: "${p}"\` uses a mid-ramp surface anchor (steps 4\u201313). Child tones derived from this surface may clamp and collapse contrast.`,hint:"Prefer edge anchors: shift-0\u20133 for light surfaces, shift-14\u201317 for dark. Mid anchors are only correct for intentionally inverted/highlighted regions."})}let b=l.dataDensity;if(typeof b=="string"&&b!=="inherit"){let o=M(b);!o||o.family==="shift"?f.push({rule:"unknown-density",severity:"warning",category:"data-attr",path:u,message:`\`dataDensity\` "${b}" is not a valid density offset.`,hint:'Use "inherit", "increase-N", or "decrease-N" where N is 0\u20134. "shift-" is not valid for density.'}):o.n>4&&f.push({rule:"unknown-density",severity:"error",category:"data-attr",path:u,message:`\`dataDensity\` "${b}" N=${o.n} is out of range \u2014 the density scale has 5 steps (max offset: 4).`,hint:'Use "increase-N" or "decrease-N" where N \u2264 4. Density factors: [0.75, 1, 1.5, 2, 2.5].'})}let g=l.dataSize;if(typeof g=="string"&&g!=="inherit"){let o=M(g);!o||o.family==="shift"?f.push({rule:"unknown-size",severity:"warning",category:"data-attr",path:u,message:`\`dataSize\` "${g}" is not a valid size offset.`,hint:'Use "inherit", "increase-N", or "decrease-N" where N is 0\u20137. "shift-" is not valid for size.'}):o.n>7&&f.push({rule:"unknown-size",severity:"error",category:"data-attr",path:u,message:`\`dataSize\` "${g}" N=${o.n} is out of range \u2014 the size scale has 8 steps (max offset: 7).`,hint:'Use "increase-N" or "decrease-N" where N \u2264 7.'})}if(n.rules&&n.rules.length>0)for(let o of n.rules){let h;try{h=o.check(l,u,c)}catch(a){continue}for(let a of h)f.push({rule:o.id,severity:(D=a.severity)!=null?D:o.severity,category:o.category,path:u,message:a.message,hint:a.hint})}let L=[];S(m,u,L,!1,n),q(l._doctorDisable,f,L,u,s)}function x(e,t={}){let s=C(e,t),i={error:0,warning:0,info:0,total:s.length};for(let n of s)i[n.severity]+=1;return{ok:i.error===0,issues:s,summary:i}}function W(e){if(e.length===0)return"\u2713 No issues found.";let t=s=>s==="error"?"\u2717":s==="warning"?"\u26A0":"i";return e.map(s=>`${t(s.severity)} [${s.rule}] ${s.path}
|
|
1
|
+
"use strict";var Domphy=(()=>{var L=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var s in t)L(e,s,{get:t[s],enumerable:!0})},et=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Q(t))!tt.call(e,r)&&r!==s&&L(e,r,{get:()=>t[r],enumerable:!(i=X(t,r))||i.enumerable});return e};var st=e=>et(L({},"__esModule",{value:!0}),e);var vt={};U(vt,{doctor:()=>C});var C={};U(C,{diagnose:()=>O,fix:()=>J,format:()=>Z,validate:()=>E});var it=e=>{let t=s=>s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;return e.map(t)};var F=e=>{let t=parseInt(e.slice(1,3),16)/255,s=parseInt(e.slice(3,5),16)/255,i=parseInt(e.slice(5,7),16)/255;return it([t,s,i])};var z=e=>{let[t,s,i]=e,r=.4124564*t+.3575761*s+.1804375*i,o=.2126729*t+.7151522*s+.072175*i,l=.0193339*t+.119192*s+.9503041*i,c=.95047,u=1,f=1.08883,p=y=>y>.008856?Math.cbrt(y):7.787*y+16/116,k=p(r/c),g=p(o/u),v=p(l/f);return[116*g-16,500*(k-g),200*(g-v)]};var H=e=>{let[t,s,i]=e,r=Math.sqrt(s*s+i*i);if(r<1e-4)return[t,0,0];let o=(Math.atan2(i,s)*180/Math.PI+360)%360;return o>=359.9999&&(o=0),[t,r,o]};var q=e=>{let t=e.match(/\d+(\.\d+)?/g);if(!t||t.length<3)throw new Error("Invalid CSS rgb()");let s=i=>{let r=i/255;return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)};return[s(Number(t[0])),s(Number(t[1])),s(Number(t[2]))]};var W=["a","abbr","address","article","aside","audio","b","base","blockquote","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","slot","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","bdi","bdo","math","menu","search","area","embed","hr","animate","animateMotion","animateTransform","circle","clipPath","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","prefetch","radialGradient","rect","set","solidColor","stop","svg","switch","symbol","tbreak","text","textPath","tspan","use","view"];var V=["svg","circle","path","rect","ellipse","line","polyline","polygon","g","defs","use","symbol","linearGradient","radialGradient","stop","clipPath","mask","filter","text","tspan","textPath","image","pattern","marker","animate","animateTransform","animateMotion","feGaussianBlur","feComposite","feColorMatrix","feMerge","feMergeNode","feOffset","feFlood","feBlend","foreignObject"],G=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"];var nt=["onAbort","onAuxClick","onBeforeMatch","onBeforeToggle","onBlur","onCancel","onCanPlay","onCanPlayThrough","onChange","onClick","onClose","onContextLost","onContextMenu","onContextRestored","onCopy","onCueChange","onCut","onDblClick","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDragStart","onDrop","onDurationChange","onEmptied","onEnded","onError","onFocus","onFormData","onInput","onInvalid","onKeyDown","onKeyPress","onKeyUp","onLoad","onLoadedData","onLoadedMetadata","onLoadStart","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onPaste","onPause","onPlay","onPlaying","onProgress","onRateChange","onReset","onResize","onScroll","onScrollEnd","onSecurityPolicyViolation","onSeeked","onSeeking","onSelect","onSlotChange","onStalled","onSubmit","onSuspend","onTimeUpdate","onToggle","onVolumeChange","onWaiting","onWheel","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onGotPointerCapture","onLostPointerCapture","onCompositionStart","onCompositionUpdate","onCompositionEnd","onTransitionEnd","onTransitionStart","onAnimationStart","onAnimationEnd","onAnimationIteration","onFullscreenChange","onFullscreenError","onFocusIn","onFocusOut"],kt=nt.reduce((e,t)=>{let s=t.slice(2).toLowerCase();return e[s]=t,e},{});var Mt=typeof process!="undefined"&&process.env!=null&&process.env.NODE_ENV!=="production";var rt=new Set([...W,...V]),S=new Set(G);function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){for(let t in e)if(rt.has(t))return t}var ot=new Set(["$","style","_key","_portal","_context","_metadata","_doctorDisable"]),at=new Set(["fontSize","lineHeight","fontWeight","letterSpacing","fontFamily","textDecoration"]),lt=new Set(["color","backgroundColor","background","borderColor","border","outlineColor","outline","fill","stroke"]),ht=new Set(["color","fill","stroke","backgroundColor","outlineColor","borderColor","caretColor","accentColor","columnRuleColor","textDecorationColor"]),ut=new Set(["transparent","currentcolor","inherit","initial","unset","none","auto","revert","revert-layer",""]),K=/#[0-9a-fA-F]{3,8}\b|\b(?:rgba?|hsla?)\s*\(/,ct=new Set(["margin","marginTop","marginRight","marginBottom","marginLeft","marginInline","marginBlock","marginInlineStart","marginInlineEnd","marginBlockStart","marginBlockEnd","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingInline","paddingBlock","paddingInlineStart","paddingInlineEnd","paddingBlockStart","paddingBlockEnd","gap","rowGap","columnGap"]),ft=/^(\d+(?:\.\d+)?)(rem|em|px)$/;function x(e){let t=e.match(/^(increase|decrease|shift)-(\d+)$/);return t?{family:t[1],n:parseInt(t[2],10)}:null}function dt(e){if(e==="inherit"||e==="base"||/^-?\d+$/.test(e))return!0;let t=x(e);return t?t.n<=17:!1}function mt(e){try{let t=e.trim(),s;if(t.startsWith("#")){let o=t;if(o.length===9&&(o=o.slice(0,7)),o.length===5&&(o=o.slice(0,4)),o.length===4&&(o=`#${o[1]}${o[1]}${o[2]}${o[2]}${o[3]}${o[3]}`),o.length!==7)return null;s=F(o)}else if(/^rgba?\s*\(/.test(t))s=q(t);else return null;let i=z(s),r=H(i);return[r[0],r[1],r[2]]}catch(t){return null}}var pt=/#[0-9a-fA-F]{3,8}\b|rgba?\s*\([^)]*\)/;function gt(e){let t=pt.exec(e);return t?t[0]:null}function yt(e){let[t,s,i]=e,r=Math.round((t-50)/10),o=Math.max(-9,Math.min(9,r)),l;Math.abs(o)<=1?l='"base"':o<0?l=`"decrease-${Math.abs(o)}"`:l=`"increase-${o}"`;let c;return s<12?c="neutral":i<30||i>=330?c="error":i<75?c="warning":i<165?c="success":(i<265,c="primary"),`(l) => themeColor(l, ${l}, "${c}") [perceptual LCH L=${Math.round(t)} C=${Math.round(s)} h=${Math.round(i)}\xB0]`}function bt(e,t){let s=ft.exec(t);if(!s)return null;let i=parseFloat(s[1]),r=s[2],o;return r==="rem"||r==="em"?o=Math.round(i*4):o=Math.round(i/4),o<=0?null:`${e}: themeSpacing(${o}) \u2014 themeSpacing(n)=n/4em, so ${o}/4=${o/4}em \u2248 ${t} at default density`}function Y(e,t,s,i,r){if(e===!0){for(let o of s)o.path!==i&&r.push(o);return}if(e!=null&&e!==!1){let o=new Set(Array.isArray(e)?e:[String(e)]);for(let l of t)o.has(l.rule)||r.push(l);for(let l of s)l.path===i&&o.has(l.rule)||r.push(l);return}r.push(...t),r.push(...s)}function O(e,t={}){let s=[];if(R(e,"",s,!1,t),t.only!==void 0){if(t.only.length===0)return[];let i=new Set(t.only);return s.filter(r=>i.has(r.rule))}if(t.exclude&&t.exclude.length>0){let i=new Set(t.exclude);return s.filter(r=>!i.has(r.rule))}return s}function R(e,t,s,i,r){var A,I,B;let o=r.runReactive!==!1;if(typeof e=="function"){if(!o)return;let n;try{n=e(()=>{})}catch(h){return}R(n,t,s,!0,r);return}if(Array.isArray(e)){let n=e.filter(a=>b(a)&&_(a));i&&(n.length>1&&n.some(a=>a._key===void 0)&&s.push({rule:"missing-key",severity:"warning",category:"key",path:t||"(list)",message:"Dynamic list child without `_key` \u2014 reordered/keyed lists need a stable `_key` for correct reconcile.",hint:"Add `_key: <stable id>` to each item produced by the reactive function."}),n.length>1&&n.every((a,d)=>a._key===d)&&s.push({rule:"unstable-key",severity:"warning",category:"key",path:t||"(list)",message:"Dynamic list `_key` values are the array index (0, 1, 2, \u2026) \u2014 index keys are unstable across reorders/inserts.",hint:"Key by a stable identity from the data (e.g. `_key: item.id`), not the loop index."}));let h=new Map;for(let a of n){let d=a._key;if(d==null)continue;let m=`${typeof d}:${String(d)}`;h.set(m,((A=h.get(m))!=null?A:0)+1)}for(let[a,d]of h)if(d>1){let m=a.slice(a.indexOf(":")+1);s.push({rule:"duplicate-key",severity:"error",category:"key",path:t||"(list)",message:`Duplicate \`_key\` "${m}" among ${d} siblings \u2014 keys must be unique within a list.`,hint:"Give each sibling a distinct stable `_key` (e.g. a record id, not a constant)."})}e.forEach((a,d)=>{R(a,`${t}[${d}]`,s,!1,r)});return}if(!b(e))return;let l=e,c=_(l),u=c?t?`${t} > ${c}`:c:t||"(root)",f=[];if(!c){let n=Object.keys(l).filter(h=>!ot.has(h)&&!h.startsWith("_on")&&!h.startsWith("on")&&!h.startsWith("data")&&!h.startsWith("aria"));n.length===1&&f.push({rule:"unknown-tag",severity:"warning",category:"structure",path:u,message:`"${n[0]}" is not a known HTML/SVG tag \u2014 likely a typo.`,hint:"An element's first key must be a valid tag (div, button, span, \u2026)."}),Y(l._doctorDisable,f,[],u,s);return}let p=l[c];if(S.has(c)&&p!==null&&p!==void 0&&f.push({rule:"void-content",severity:"error",category:"structure",path:u,message:`Void tag "${c}" must have null content (got ${Array.isArray(p)?"array":typeof p}).`,hint:`Write { ${c}: null, \u2026 } and put attributes as sibling keys.`}),b(l.style)){let n=l.style;for(let h in n){let a=n[h];if(at.has(h)&&typeof a!="function"&&f.push({rule:"inline-typography",severity:"warning",category:"typography",path:u,message:`Inline \`${h}\` \u2014 avoid inline typography styles.`,hint:"Use a typography patch (paragraph()/heading()/small()/strong()/\u2026) via $ so the theme owns the type scale."}),lt.has(h)&&typeof a=="string"&&K.test(a)){let d=(I=gt(a))!=null?I:a,m=mt(d),M=m?yt(m):"(l) => themeColor(l, tone, colorName)";f.push({rule:"raw-theme-value",severity:"info",category:"theme",path:u,message:`Inline \`${h}\` uses a literal color (${a}).`,hint:`Prefer a theme token \u2014 ${M} \u2014 so theming and dark mode apply.`})}if(ht.has(h)&&typeof a=="string"&&!K.test(a)&&!a.includes("(")&&!a.startsWith("--")&&!ut.has(a.trim().toLowerCase())&&f.push({rule:"raw-theme-value",severity:"info",category:"theme",path:u,message:`Inline \`${h}\` uses a CSS named color ("${a}").`,hint:`CSS named colors like "${a}" bypass theming and dark mode. Prefer (l) => themeColor(l, tone, colorName) \u2014 so the theme context applies.`}),ct.has(h)&&typeof a=="string"){let d=bt(h,a);d&&f.push({rule:"raw-spacing-value",severity:"info",category:"theme",path:u,message:`Inline \`${h}: "${a}"\` uses a literal spacing value.`,hint:`Prefer themeSpacing() for theme density: ${d}`})}}}let k=b(l.style)?l.style.backgroundColor:void 0;if(typeof k=="function"&&o){let n;try{n=k(()=>{})}catch(h){}if(typeof n=="string"){let h=n.match(/var\(--[\w-]+-(\d+)\)$/);h&&parseInt(h[1],10)>0&&f.push({rule:"tone-background-inherit",severity:"warning",category:"theme",path:u,message:`\`style.backgroundColor\` uses a fixed tone (resolves to "${n}" at base context) instead of "inherit".`,hint:'backgroundColor should always be (l) => themeColor(l, "inherit"). To shift the surface tone, set dataTone on the container \u2014 it applies to all children uniformly.'})}}{let n=b(l.style)?l.style:null,h=n==null?void 0:n.color,a=n==null?void 0:n.backgroundColor;if(o&&typeof h=="function"&&typeof a=="function"){let d,m;try{d=h(()=>{}),m=a(()=>{})}catch(w){}let M=w=>{if(typeof w!="string")return null;let P=w.match(/var\(--[\w-]+-(\d+)\)$/);return P?parseInt(P[1],10):null},$=M(d),T=M(m);if($!==null&&T!==null){let w=Math.abs($-T);w<9&&f.push({rule:"low-contrast",severity:"warning",category:"theme",path:u,message:`Text/background shift gap is ${w} (shift-${$} vs shift-${T}) \u2014 contrast may be insufficient.`,hint:"Aim for \u22659 shift steps between text and surface. E.g. shift-0 bg + shift-9 text, or shift-11 text on a shift-0 surface. Increase the gap or rely on a parent dataTone to open it."})}}}let g=l.dataTone;if(typeof g=="string")if(!dt(g))f.push({rule:"unknown-tone",severity:"warning",category:"data-attr",path:u,message:`\`dataTone\` "${g}" is not a valid tone.`,hint:'Use "inherit", "base", a number, or "shift-N"/"increase-N"/"decrease-N" with N \u2264 17 (the ramp has 18 steps). Words like "surface"/"text" are not tones.'});else{let n=x(g);(n==null?void 0:n.family)==="shift"&&n.n>=4&&n.n<=13&&f.push({rule:"middle-surface-anchor",severity:"warning",category:"data-attr",path:u,message:`\`dataTone: "${g}"\` uses a mid-ramp surface anchor (steps 4\u201313). Child tones derived from this surface may clamp and collapse contrast.`,hint:"Prefer edge anchors: shift-0\u20133 for light surfaces, shift-14\u201317 for dark. Mid anchors are only correct for intentionally inverted/highlighted regions."})}let v=l.dataDensity;if(typeof v=="string"&&v!=="inherit"){let n=x(v);!n||n.family==="shift"?f.push({rule:"unknown-density",severity:"warning",category:"data-attr",path:u,message:`\`dataDensity\` "${v}" is not a valid density offset.`,hint:'Use "inherit", "increase-N", or "decrease-N" where N is 0\u20134. "shift-" is not valid for density.'}):n.n>4&&f.push({rule:"unknown-density",severity:"error",category:"data-attr",path:u,message:`\`dataDensity\` "${v}" N=${n.n} is out of range \u2014 the density scale has 5 steps (max offset: 4).`,hint:'Use "increase-N" or "decrease-N" where N \u2264 4. Density factors: [0.75, 1, 1.5, 2, 2.5].'})}let y=l.dataSize;if(typeof y=="string"&&y!=="inherit"){let n=x(y);!n||n.family==="shift"?f.push({rule:"unknown-size",severity:"warning",category:"data-attr",path:u,message:`\`dataSize\` "${y}" is not a valid size offset.`,hint:'Use "inherit", "increase-N", or "decrease-N" where N is 0\u20137. "shift-" is not valid for size.'}):n.n>7&&f.push({rule:"unknown-size",severity:"error",category:"data-attr",path:u,message:`\`dataSize\` "${y}" N=${n.n} is out of range \u2014 the size scale has 8 steps (max offset: 7).`,hint:'Use "increase-N" or "decrease-N" where N \u2264 7.'})}if(r.rules&&r.rules.length>0)for(let n of r.rules){let h;try{h=n.check(l,u,c)}catch(a){continue}for(let a of h)f.push({rule:n.id,severity:(B=a.severity)!=null?B:n.severity,category:n.category,path:u,message:a.message,hint:a.hint})}let j=[];R(p,u,j,!1,r),Y(l._doctorDisable,f,j,u,s)}function E(e,t={}){let s=O(e,t),i={error:0,warning:0,info:0,total:s.length};for(let r of s)i[r.severity]+=1;return{ok:i.error===0,issues:s,summary:i}}function Z(e){if(e.length===0)return"\u2713 No issues found.";let t=s=>s==="error"?"\u2717":s==="warning"?"\u26A0":"i";return e.map(s=>`${t(s.severity)} [${s.rule}] ${s.path}
|
|
2
2
|
${s.message}${s.hint?`
|
|
3
3
|
\u2192 ${s.hint}`:""}`).join(`
|
|
4
|
-
`)}function
|
|
4
|
+
`)}function N(e){if(Array.isArray(e))return e.map(N);if(b(e)){let t={};for(let s in e)t[s]=N(e[s]);return t}return e}function J(e,t={}){let s=N(e),i=[];return D(s,"",i),{tree:s,applied:i,report:E(s,t)}}function D(e,t,s){if(Array.isArray(e)){for(let[o,l]of e.entries())D(l,`${t}[${o}]`,s);return}if(!b(e))return;let i=_(e);if(!i)return;let r=t?`${t} > ${i}`:i;S.has(i)&&e[i]!==null&&e[i]!==void 0&&(e[i]=null,s.push({rule:"void-content",path:r,message:`Void tag <${i}> cannot have content \u2014 cleared to null.`})),D(e[i],r,s)}return st(vt);})();
|
|
5
5
|
//# sourceMappingURL=doctor.global.js.map
|