@taprootio/espalier 7.1.1 → 7.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 (50) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/custom-elements.json +8073 -5734
  3. package/dist/button/paint-registration.js +1 -0
  4. package/dist/cli/theme-check.js +2 -2
  5. package/dist/footer/paint-registration.js +1 -0
  6. package/dist/header/esp-header-button.js +6 -2
  7. package/dist/header/esp-header.js +8 -4
  8. package/dist/header/header-geometry-controller.js +1 -1
  9. package/dist/header/is-tall-header-paint.d.ts +7 -0
  10. package/dist/header/is-tall-header-paint.js +1 -0
  11. package/dist/header/paint-registration.js +1 -0
  12. package/dist/index.d.ts +2 -1
  13. package/dist/menu/esp-menu-group.js +8 -8
  14. package/dist/menu/esp-menu-item.js +8 -8
  15. package/dist/menu/esp-menu.js +10 -6
  16. package/dist/menu/navigation-focus-outline.js +8 -0
  17. package/dist/menu/navigation-paint.js +1 -0
  18. package/dist/menu/paint-registration.js +1 -0
  19. package/dist/shared/color-engine.js +1 -1
  20. package/dist/shared/composed-dom.js +1 -0
  21. package/dist/shared/configured-brand-color.js +1 -0
  22. package/dist/shared/configured-brand.js +5 -5
  23. package/dist/shared/css-named-colors.js +1 -0
  24. package/dist/shared/paint-catalog.d.ts +27 -0
  25. package/dist/shared/paint-catalog.js +1 -0
  26. package/dist/shared/paint-color.d.ts +25 -0
  27. package/dist/shared/paint-color.js +1 -0
  28. package/dist/shared/paint-fit.js +1 -0
  29. package/dist/shared/paint-identity.js +1 -0
  30. package/dist/shared/paint-types.d.ts +88 -0
  31. package/dist/shared/paint-types.js +0 -0
  32. package/dist/shared/theme-fit-report.d.ts +10 -2
  33. package/dist/shared/theme-fit-report.js +1 -1
  34. package/dist/shared/theme.d.ts +3 -24
  35. package/dist/shared/theme.js +1 -1
  36. package/dist/shared/token-pairings.d.ts +25 -0
  37. package/dist/shared/token-pairings.js +1 -0
  38. package/dist/shared/wcag-contrast.d.ts +14 -0
  39. package/dist/shared/wcag-contrast.js +1 -0
  40. package/dist/testing/index.d.ts +7 -0
  41. package/dist/testing/index.js +1 -0
  42. package/dist/testing/observe-paint.d.ts +29 -0
  43. package/dist/testing/observe-paint.iife.js +3 -0
  44. package/dist/testing/observe-paint.js +3 -0
  45. package/dist/testing/paint-bands.js +1 -0
  46. package/dist/testing/paint-coverage.d.ts +14 -0
  47. package/dist/testing/paint-coverage.js +1 -0
  48. package/dist/testing/paint-dom.js +1 -0
  49. package/dist/testing/svg-paint.js +1 -0
  50. package/package.json +6 -1
@@ -0,0 +1,14 @@
1
+ import type { PaintEntriesByRole, PaintEntry } from "../shared/paint-types.js";
2
+ import type { PaintObservation } from "./observe-paint.js";
3
+ type ExpectedPaint = PaintEntry & {
4
+ role: string;
5
+ };
6
+ export interface PaintCoverageAudit {
7
+ /** Visible pairs absent from the enabled catalog. */
8
+ unlisted: PaintObservation[];
9
+ /** Enabled catalog pairs for which there was no visible observation. */
10
+ unobserved: ExpectedPaint[];
11
+ }
12
+ /** Compare driven states with enabled entries, keeping one witness per missing paint pair. */
13
+ export declare function auditPaintCoverage(observations: readonly PaintObservation[], expected: PaintEntriesByRole): PaintCoverageAudit;
14
+ export {};
@@ -0,0 +1 @@
1
+ import{firstPaintByIdentity as n}from"../shared/paint-identity.js";function p(r,s){const a=Object.entries(s).flatMap(([t,o])=>o.map(d=>({role:t,...d}))),e=n(a),i=n(r);return{unlisted:[...i].filter(([t])=>!e.has(t)).map(([,t])=>t),unobserved:[...e].filter(([t])=>!i.has(t)).map(([,t])=>t)}}export{p as auditPaintCoverage};
@@ -0,0 +1 @@
1
+ import{composedParent as m,isShadowRoot as tt}from"../shared/composed-dom.js";import{compositePaint as U,parsePaintColor as ot}from"../shared/paint-color.js";const M="http://www.w3.org/2000/svg",W={r:0,g:0,b:0,alpha:0},I={r:1,g:1,b:1,alpha:1};function mt(o){const t=[],e=[];function n(r){if(r.nodeType===Node.TEXT_NODE){r.textContent?.trim()&&e.push(r);return}if(r.nodeType===Node.ELEMENT_NODE){const i=r;if(i.matches("style, script, template, defs, symbol"))return;if(t.push(i),i.shadowRoot){n(i.shadowRoot);return}if(i.localName==="slot"&&i.namespaceURI!==M){const c=i.assignedNodes();if(c.length){c.forEach(n);return}}}r.childNodes.forEach(n)}return n(o),{elements:t,text:e}}function _(o,t){const e=[];for(let r=o;r;r=m(r)){const i=r.localName;if(e.unshift(r.id?`${i}#${r.id}`:i+[...r.classList].slice(0,2).map(c=>`.${c}`).join("")),r.id)break}const n=t?.data.trim().slice(0,70);return e.join(" > ")+(n?` "${n}"`:"")}function yt(o){const t=[o];for(const e of t)for(const n of e.querySelectorAll("*"))n.shadowRoot&&t.push(n.shadowRoot);return t}function wt(o,t){const e=new CSSStyleSheet;e.replaceSync("* { pointer-events: auto !important; }");const n=new CSSStyleSheet;n.replaceSync(":host, *, ::slotted(*) { pointer-events: auto !important; }");const r=[];try{for(const i of o){const c=[...i.adoptedStyleSheets];i.adoptedStyleSheets=[...c,tt(i)?n:e],r.push([i,c])}return t()}finally{for(const[i,c]of r)i.adoptedStyleSheets=c}}function et(o){return o.width<=0||o.height<=0?[]:[.5,.25,.75].flatMap(t=>[.5,.25,.75].map(e=>({x:o.left+t*o.width,y:o.top+e*o.height})))}function bt(o){const t=o.ownerDocument.createRange();return t.selectNodeContents(o),[...t.getClientRects()].flatMap(et)}function nt(o,t){for(let e=o;e&&e!==t.host;e=m(e))if(e.getRootNode()===t)return!0;return!1}function X(o,{x:t,y:e}){const n=[],r=new Set,i=c=>{if(r.has(c))return;r.add(c);const d=c.shadowRoot;d&&d.elementsFromPoint(t,e).filter(u=>nt(u,d)).forEach(i),n.push(c)};return o.elementsFromPoint(t,e).forEach(i),n}function rt(o,t){return Math.abs(o.alpha-t.alpha)<=.001&&Math.abs(o.r-t.r)<=.001&&Math.abs(o.g-t.g)<=.001&&Math.abs(o.b-t.b)<=.001}function z(o,t){return{...o,alpha:o.alpha*t}}function T(o){return o.trim().toLowerCase()==="transparent"?W:ot(o)}function st(o,t){if(T(t))return t;const e=o.ownerDocument,n=o.namespaceURI===M?e.createElementNS(M,"g"):e.createElement("span");if(n.style.cssText="display:none!important;visibility:hidden!important",n.style.setProperty("color",t,"important"),!n.style.color)return t;(o.shadowRoot??o).append(n);try{const r=y(n).color;return T(r)?r:(n.style.setProperty("color",`oklch(from ${r} l c h / alpha)`,"important"),y(n).color)}finally{n.remove()}}function y(o){return o.ownerDocument.defaultView.getComputedStyle(o)}function xt(o){const t=y(o);return t.display!=="none"&&t.visibility==="visible"&&it(o)>0}function it(o){return Y(o).reduce((t,e)=>t*e.opacity,1)}function q(o,t){for(let e=t;e;e=m(e))if(e===o)return!0;return!1}function ct(o){let t=o;for(let e=m(t);e&&y(t).display==="contents";e=m(t))t=e;return t}function at(o,t){for(let e=o,n=m(e);n&&!e.matches(":popover-open, dialog:modal");e=n,n=m(e)){const{overflowX:r,overflowY:i}=y(n);if(r==="visible"&&i==="visible")continue;const c=n.getBoundingClientRect();if(r!=="visible"&&(t.x<c.left||t.x>=c.right)||i!=="visible"&&(t.y<c.top||t.y>=c.bottom))return!0}return!1}function ut(o,t){function e(S,C){o.style.setProperty("left",`${S}px`,"important"),o.style.setProperty("top",`${C}px`,"important");const h=o.getBoundingClientRect();return{x:(h.left+h.right)/2,y:(h.top+h.bottom)/2}}const n=t.x-.5,r=t.y-.5,i=e(n,r);if(Math.abs(i.x-t.x)<.05&&Math.abs(i.y-t.y)<.05)return;const c=e(n+1,r),d=e(n,r+1),u=c.x-i.x,f=c.y-i.y,a=d.x-i.x,x=d.y-i.y,p=u*x-f*a;if(Math.abs(p)<1e-6)return;const v=t.x-i.x,w=t.y-i.y;e(n+(x*v-a*w)/p,r+(u*w-f*v)/p)}function lt(o,t){const e=o.ownerDocument,n=e.createElement("span");n.style.cssText=["all:initial!important","display:block!important","width:1px!important","height:1px!important","position:fixed!important","z-index:auto!important","opacity:0!important","pointer-events:auto!important","visibility:visible!important"].join(";"),n.setAttribute("aria-hidden","true"),(o.shadowRoot??o).append(n);try{ut(n,t);const r=X(e,t),i=r.indexOf(n);return i<0?void 0:{above:r.slice(0,i),below:r.slice(i+1).filter(c=>c!==o)}}finally{n.remove()}}function Y(o){const t=[];for(let e=o;e;e=m(e)){const n=Number(y(e).opacity);n<1&&t.unshift({element:e,opacity:n})}return t}function J(o,t,e){const n=T(st(o,t));if(!n)throw new Error(`Cannot resolve ${e} "${t}" on ${_(o)}`);return n}function ft(o,t){const e=y(o);if(e.visibility!=="visible"||t.some(r=>r.opacity===0))return null;const n=J(o,e.backgroundColor,"background paint");return n.alpha===0?null:{element:o,color:n,sourceColor:n,groups:t}}function pt(o,t,e){if("uncertainty"in t)throw new Error(t.uncertainty);const n=J(o,t.rawColor,"overlapping paint");return{element:o,color:z(n,t.opacity),sourceColor:n,groups:[...e,...t.groups??[]]}}function dt(o,t){return o.length===t.length&&o.every((e,n)=>e.element===t[n].element)}function D(o,t,e=0){let n=t;for(let r=o.length-1;r>=0;r--){const i=o[r],c=i.groups[e];if(!c){n=U(i.color,n);continue}let d=r;for(;o[d-1]?.groups[e]?.element===c.element;)d--;const u=D(o.slice(d,r+1),W,e+1);n=U(z(u,c.opacity),n),r=d}return n}function vt(o,t){const e=new Map,n=new WeakMap,r=new WeakMap;function i(u){const f=`${u.x},${u.y}`;let a=e.get(f);return a||(a=X(o,u),e.set(f,a)),a}function c(u){let f=r.get(u);return f||(f=Y(u),r.set(u,f)),f}function d(u){return n.has(u)||n.set(u,ft(u,c(u))),n.get(u)??null}return function(f,a,x){const p=i(a);if(p.length===0)return;let v;function w(s){return s===a.svgRoot||s.namespaceURI!==M||s.localName!=="svg"?[]:(v??=new Set(p),t(s,a,v))}const S=ct(f),C=p.includes(S)?S:a.retarget&&p.includes(a.retarget)?a.retarget:void 0;if(a.svgRoot&&!C)return;const h=a.svgRoot??C??S,P=p.indexOf(h);let k,R;if(a.inside){if(at(f,a))return;const s=i(a.inside),l=s.indexOf(h);if(l<0)return;const V=lt(h,a);if(V)({above:k,below:R}=V);else{const Z=new Set(s),F=p.find(g=>!Z.has(g)&&(d(g)||w(g).length));if(F)throw new Error(`Cannot order outward paint against ${_(F)}`);const H=new Set(s.slice(0,l));k=p.filter(g=>H.has(g)),R=p.filter(g=>g!==h&&!H.has(g))}}else{if(P<0)return;k=p.slice(0,P),R=p.slice(P+(x?0:1))}const K=c(f),b=a.local,$=[...K,...b?.groups??[]],Q=new Set($.map(s=>s.element)),A=[];function O(s){return!s||s.color.alpha===0?!0:s.color.alpha===1&&s.groups.every(l=>Q.has(l.element))?!1:(A.push(s),!0)}function E(s){const l=s.element??f;return s.requiresHit&&!p.includes(l)&&(!s.retarget||!p.includes(s.retarget))?null:pt(l,s,c(l))}for(const s of k)if(!(q(s,h)||q(h,s)&&(a.svgRoot||x&&a.inside))){for(const l of w(s))if(!O(E(l)))return;if(!O(d(s)))return}for(const s of b?.above??[])if(!O(E(s)))return;const N=[];function B(s){return!s||s.color.alpha===0?!0:(N.push(s),s.color.alpha<1||s.groups.length>0)}let L=!0,G=!!b?.opaqueInk;for(const s of b?.below??[]){const l=E(s);if(!(!l||l.color.alpha===0)&&!(G&&b?.opaqueInk&&l.color.alpha===1&&rt(b.opaqueInk,l.color)&&dt($,l.groups))&&(G=!1,L=B(l),!L))break}if(L){for(const s of R)if(!(a.svgRoot&&s!==h&&q(h,s))&&(w(s).some(l=>!B(E(l)))||!B(d(s))))break}const j=N[0];return{color:D([...A,...N],I),sourceColor:j?.sourceColor??I,sourceElement:j?.element,paintForeground:s=>{const l={element:f,color:s,sourceColor:s,groups:$};return D([...A,l,...N],I)}}}}export{M as SVG_NAMESPACE,yt as allShadowScopes,st as browserColor,mt as composedNodes,vt as createPaintSampler,T as cssPaintColor,rt as equalColor,xt as hasVisibleBox,_ as locationOf,z as opacity,et as sampleRect,y as styleOf,bt as textPoints,wt as withPaintHitTesting};
@@ -0,0 +1 @@
1
+ import{isShadowRoot as W}from"../shared/composed-dom.js";import{SVG_NAMESPACE as w,browserColor as Q,cssPaintColor as X,hasVisibleBox as Z,locationOf as N,sampleRect as U,styleOf as D}from"./paint-dom.js";const G=new Set(["path","circle","ellipse","rect","line","polygon","polyline"]),tt=new Set([...G,"symbol","g","svg","defs","use"]),q=["color","fill","fill-opacity","stroke","stroke-opacity","stroke-width","visibility"],F=new Set([...q,"display","opacity","d","x","y","x1","x2","y1","y2","points","width","height","cx","cy","r","rx","ry","viewBox","preserveAspectRatio","transform","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","fill-rule","paint-order","vector-effect","overflow"]),H=new WeakMap;function T(t){return t.href.baseVal||null}function L(t){const e=T(t)?.trim();if(!e||e.startsWith("#"))return;const n=new URL(e,t.baseURI);if(!n.hash)return;const r=decodeURIComponent(n.hash.slice(1));return n.hash="",{url:n,id:r}}function V(t){return t.namespaceURI===w&&t.localName==="use"}async function ut(t){const e=new Map;for(const r of t){if(!V(r))continue;let o;try{o=L(r)}catch{continue}if(!o||e.has(o.url.href)||o.url.origin!==r.ownerDocument.location?.origin)continue;const{url:i}=o;if(A(i,r.ownerDocument))continue;let c=H.get(r.ownerDocument);c||(c=new Map,H.set(r.ownerDocument,c));let l=c.get(i.href);if(!l){const a=c;l=et(i).then(s=>(s instanceof Error&&a.delete(i.href),s)),a.set(i.href,l)}e.set(i.href,l)}const n=await Promise.all([...e].map(async([r,o])=>[r,await o]));return new Map(n)}function A(t,e){const n=new URL(e.URL);return n.hash="",t.href===n.href}async function et(t){try{const e=await fetch(t,{mode:"same-origin"});if(!e.ok)throw new Error(`SVG sprite returned HTTP ${e.status}`);const n=new DOMParser().parseFromString(await e.text(),"image/svg+xml");if(n.documentElement.namespaceURI!==w)throw new Error("Response is not an SVG sprite");return n}catch(e){return e instanceof Error?e:new Error(String(e))}}function nt(t,e){const n=t.getBoundingClientRect();if(n.width===0&&n.height===0)return[];const r=new DOMRect(n.x-(n.width?0:e/2),n.y-(n.height?0:e/2),n.width||e,n.height||e),o=U(r);if("getTotalLength"in t&&"getScreenCTM"in t){const i=t,c=i.getScreenCTM();if(c){const l=i.getTotalLength();for(let a=0;a<=16;a++){const s=i.getPointAtLength(l*a/16),f=new DOMPoint(s.x,s.y).matrixTransform(c);o.push({x:f.x,y:f.y})}}}return o}function rt(t,e,n){const r=[];if(t.visibility!=="visible"||t.display==="none")return r;t.fill!=="none"&&n!=="line"&&r.push({source:"fill",color:t.fill,opacity:Number(t.fillOpacity),points:e}),t.stroke!=="none"&&parseFloat(t.strokeWidth)>0&&r.push({source:"stroke",color:t.stroke,opacity:Number(t.strokeOpacity),points:e});const i=[...t.getPropertyValue("paint-order").split(/\s+/),"fill","stroke"];return r.sort((c,l)=>i.indexOf(c.source)-i.indexOf(l.source))}function ot(t,e){const n=t.getScreenCTM()?.inverse();return n?({x:r,y:o})=>{const i=new DOMPoint(r,o).matrixTransform(n);return e==="fill"?t.isPointInFill(i):t.isPointInStroke(i)}:()=>!1}function it(t,e){const n=T(t)?.trim();if(!n)throw new Error("SVG use has no href");let r,o;const i=L(t);if(n.startsWith("#")||i&&A(i.url,t.ownerDocument)){const l=t.getRootNode();r=W(l)?l:t.ownerDocument,o=i?.id??decodeURIComponent(n.slice(1))}else{if(!i)throw new Error("SVG use does not identify a sprite fragment");const l=e.get(i.url.href);if(l instanceof Error)throw l;if(!l)throw new Error("SVG use requires a readable same-origin sprite");if(l.querySelector("style"))throw new Error("External SVG sprite styles cannot be inspected in its rendered instance");r=l,o=i.id}const c=r.getElementById(o);if(!c||c.namespaceURI!==w)throw new Error(`SVG paint target #${o} was not found`);return{target:c,scope:r}}function P(t,e){return(t.ownerDocument.defaultView&&D(t).getPropertyValue(e)||t.style.getPropertyValue(e)||t.getAttribute(e)||"").trim()}function I(t,e){const n=P(t,e);return n==="none"?"":n}function _(t){if(I(t,"mask-image")||I(t,"mask"))throw new Error(`Unsupported SVG sprite mask at ${N(t)}`)}function j(t,e){const n=I(t,"clip-path");if(!n)return;const r=n.match(/^url\((?:"([^"]+)"|'([^']+)'|([^)]*))\)$/),o=(r?.[1]??r?.[2]??r?.[3])?.trim();let i;if(o?.startsWith("#"))i=o.slice(1);else if(o){const g=new URL(o,t.baseURI),u=g.hash.slice(1);g.hash="",A(g,t.ownerDocument)&&(i=u)}const c=i&&e.getElementById(decodeURIComponent(i)),l=c&&c.firstElementChild,a=c&&c.getAttribute("clipPathUnits"),s=()=>new Error(`Unsupported SVG sprite clip-path "${n}" at ${N(t)}`);if(!c||c.namespaceURI!==w||c.localName!=="clipPath"||a!==null&&a!=="userSpaceOnUse"||c.children.length!==1||!l||l.namespaceURI!==w||l.localName!=="rect")throw s();const f=l;for(const g of[c,f])if(["transform","translate","rotate","scale","clip-path","mask-image","mask"].some(u=>I(g,u))||P(g,"display")==="none"||P(g,"visibility")==="hidden")throw s();function p(g){const u=P(f,g);if(!u||u==="auto")return 0;if(!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:px)?$/.test(u))throw s();return parseFloat(u)}if(p("rx")!==0||p("ry")!==0)throw s();return{x:p("x"),y:p("y"),width:p("width"),height:p("height")}}function Y(t,e){if(!t)return{bounds:new DOMRect,contains:()=>!1};const n=t.inverse(),r=[[e.x,e.y],[e.x+e.width,e.y],[e.x,e.y+e.height],[e.x+e.width,e.y+e.height]].map(([a,s])=>new DOMPoint(a,s).matrixTransform(t)),o=Math.min(...r.map(({x:a})=>a)),i=Math.min(...r.map(({y:a})=>a)),c=Math.max(...r.map(({x:a})=>a)),l=Math.max(...r.map(({y:a})=>a));return{bounds:new DOMRect(o,i,c-o,l-i),contains(a){const{x:s,y:f}=new DOMPoint(a.x,a.y).matrixTransform(n);return s>=e.x&&s<e.x+e.width&&f>=e.y&&f<e.y+e.height}}}function z(t,e,n=0,r=0){const o=Math.max(t.left-n,...e.map(({bounds:a})=>a.left)),i=Math.max(t.top-r,...e.map(({bounds:a})=>a.top)),c=Math.min(t.right+n,...e.map(({bounds:a})=>a.right)),l=Math.min(t.bottom+r,...e.map(({bounds:a})=>a.bottom));return c<=o||l<=i?[]:U(new DOMRect(o,i,c-o,l-i))}function st(t,e,n,r){if(!e.length)return[];const o=n&&!r?t.getScreenCTM():null,i=n/2,c=i*(o?Math.hypot(o.a,o.c):1),l=i*(o?Math.hypot(o.b,o.d):1);return z(t.getBoundingClientRect(),e,c,l)}function at(t){const e=t.getRootNode(),n=j(t,W(e)?e:t.ownerDocument);if(!n)return;function r(o){const i=P(t,o);if(!i||i==="auto")return 0;if(!/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:px)?$/.test(i))throw new Error(`Unsupported SVG use clip with ${o}="${i}" at ${N(t)}`);return parseFloat(i)}return Y(t.getScreenCTM()?.translate(r("x"),r("y"))??null,n)}function $(t,e,n,r,o){if(t.namespaceURI!==w||!tt.has(t.localName))return;if(r.has(t))throw new Error("Circular SVG use reference");const i=t.localName==="symbol"?"svg":t.localName==="use"?"g":t.localName,c=n.createElementNS(w,i);if(t.localName!=="defs"){_(t);const a=j(t,e);a&&o.set(c,a)}for(const a of["id","class",...F]){const s=t.getAttribute(a);s!==null&&c.setAttribute(a,s)}const l=t.style;for(const a of F){const s=l.getPropertyValue(a);s&&c.style.setProperty(a,s,l.getPropertyPriority(a))}if(t.localName==="use"){const a=T(t),s=a?.startsWith("#")?e.getElementById(decodeURIComponent(a.slice(1))):null;if(!s)throw new Error("Nested SVG use requires a local sprite fragment");const f=$(s,e,n,new Set([...r,t]),o);return f&&(J(c,f,p=>l.getPropertyValue(p)||t.getAttribute(p)),f.parentElement||c.append(f)),c}for(const a of t.children){const s=$(a,e,n,r,o);s&&c.append(s)}return c}function J(t,e,n){const r=(c,l)=>{const a=n(c)?.trim();return!a||a==="auto"?l:Number.isFinite(Number(a))?`${a}px`:a},o=r("x","0px"),i=r("y","0px");if(e.localName==="svg"){e.style.setProperty("x",o),e.style.setProperty("y",i);for(const c of["width","height"]){const l=e.getAttribute(c)||"100%";e.style.setProperty(c,r(c,l))}}else{const c=t.ownerDocument.createElementNS(w,"g");c.style.translate=`${o} ${i}`,t.append(c),c.append(e)}}function ct(t,e){const n=t.ownerSVGElement;if(!n||!t.parentElement||!U(n.getBoundingClientRect()).length)return;const{target:r,scope:o}=it(t,e),i=new WeakMap,c=$(r,o,t.ownerDocument,new Set,i);if(!c)return;const l=D(t),a=t.ownerDocument.createElementNS(w,"g");a.style.cssText="opacity:0!important;pointer-events:none!important";for(const p of[...q,"transform","transform-origin","transform-box"])a.style.setProperty(p,l.getPropertyValue(p));J(a,c,p=>l.getPropertyValue(p)),c.parentElement||a.append(c);const s=t.getBoundingClientRect(),f={root:c,wrapper:a,retarget:s.width||s.height?n:void 0,clips:i};f.expandingEffect=!!I(t,"filter");try{if(f.liveClip=at(t),_(t),f.expandingEffect||!["","normal"].includes(P(t,"mix-blend-mode")))throw new Error(`Unsupported SVG use filter or blend at ${N(t)}`)}catch(p){f.uncertainty=p instanceof Error?p.message:String(p)}return f}function lt(t,e){const n=new Map,r=new Map,o=new Map,i=new Map,c=new Set;for(const s of t.querySelectorAll("use"))if(!(!V(s)||s.closest("defs, symbol, foreignObject")||!Z(s)))try{const f=ct(s,e);if(!f)continue;i.set(s,f),c.add(f.wrapper)}catch(f){o.set(s,f instanceof Error?f.message:String(f))}const l=[];function a(s,f,p,g,u=[]){if(c.has(s)||s.namespaceURI!==w||s.matches("defs, symbol, foreignObject"))return;const x=D(s),R=Number(x.opacity);if(x.display==="none"||R===0)return;if(V(s)&&!p){const m=s,h=i.get(m),S=o.get(m)??(h?.expandingEffect?h.uncertainty:void 0);if(S){const d=h?.expandingEffect&&m.ownerSVGElement?m.ownerSVGElement.getBoundingClientRect():m.getBoundingClientRect(),y=m.ownerSVGElement??void 0,b=h?.liveClip;l.push({points:b?z(d,[b]):U(d),layer:{element:m,uncertainty:`${N(m)}: ${S}`,requiresHit:!0,retarget:y},retarget:y,hit:v=>v.x>=d.left&&v.x<d.right&&v.y>=d.top&&v.y<d.bottom&&(!b||b.contains(v))})}else h&&a(h.root,[],m,h.retarget,h.liveClip?[h.liveClip]:[]);return}const E=p&&i.get(p),M=E&&E.clips.get(s),k=M?[...u,Y(s.getScreenCTM(),M)]:u,C=p&&R<1?[...f,{element:s,opacity:R}]:f;if(G.has(s.localName)){const m=s,h=parseFloat(x.strokeWidth)||0,S=[...nt(m,h),...st(m,k,x.stroke==="none"?0:h,x.getPropertyValue("vector-effect")==="non-scaling-stroke")];for(const d of rt(x,S,s.localName)){const y=X(Q(s,d.color));if(d.opacity===0||y?.alpha===0)continue;const b=ot(m,d.source),v=E&&E.uncertainty;l.push({paint:v?void 0:d,points:S,layer:{element:p??s,...v?{uncertainty:v}:{rawColor:d.color,opacity:d.opacity},groups:C,requiresHit:!0,retarget:g},opaqueInk:!v&&d.opacity===1&&y?.alpha===1?y:void 0,retarget:g,projectedOwner:p,hit:B=>k.every(K=>K.contains(B))&&b(B)})}}for(const m of s.children)a(m,C,p,g,k)}try{for(const[s,{wrapper:f}]of i)s.after(f);a(t,[]);for(const[s,{paint:f,layer:p,hit:g,points:u,retarget:x,opaqueInk:R}]of l.entries()){const E=p.element,M=u.filter(g).map(h=>{const S=[],d=[];for(let y=l.length-1;y>=0;y--)y===s||!l[y].hit(h)||(y>s?S.push(l[y].layer):f&&d.push(l[y].layer));return{...h,retarget:x,svgRoot:t,local:{above:S,below:d,groups:p.groups,opaqueInk:R}}});if("uncertainty"in p){const h=r.get(E)??[];h.push({message:p.uncertainty,points:M}),r.set(E,h);continue}if(!f)continue;const k=(p.groups??[]).reduce((h,S)=>h*S.opacity,f.opacity),C=n.get(E),m={...f,opacity:k,primitiveOpacity:f.opacity,points:M};Array.isArray(C)?C.push(m):n.set(E,[m])}return{samples:n,refusals:r,layersAt(s,f){const p=l.filter(({layer:u})=>f.has(u.element)||!!(u.retarget&&f.has(u.retarget))),g=new Set(p.flatMap(({projectedOwner:u})=>u?[u]:[]));try{for(const u of g)u.after(i.get(u).wrapper);return p.reverse().flatMap(({hit:u,layer:x})=>u(s)?[x]:[])}finally{for(const u of g)i.get(u).wrapper.remove()}}}}finally{for(const{wrapper:s}of i.values())s.remove()}}function O(t){let e;for(let n=t.parentElement;n?.namespaceURI===w&&n.localName!=="foreignObject";n=n.parentElement)n.localName==="svg"&&(e=n);return e}function ht(t){const e=new WeakMap;function n(r){let o=e.get(r);return o||(o=lt(r,t),e.set(r,o)),o}return{paints(r){if(r.namespaceURI!==w||!V(r)&&!G.has(r.localName))return[];const o=O(r);return o?n(o).samples.get(r)??[]:[]},refusals(r){if(!V(r))return[];const o=O(r);return o?n(o).refusals.get(r)??[]:[]},layersAt(r,o,i){return r.namespaceURI!==w||r.localName!=="svg"||O(r)?[]:n(r).layersAt(o,i)}}}export{ht as createSvgPaintSampler,V as isSvgUse,ut as loadSprites};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taprootio/espalier",
3
- "version": "7.1.1",
3
+ "version": "7.2.0",
4
4
  "packageManager": "bun@1.3.12",
5
5
  "description": "Espalier — a themeable, accessible, framework-agnostic, enterprise-grade design system built on web standards and love.",
6
6
  "customElements": "custom-elements.json",
@@ -313,6 +313,11 @@
313
313
  "types": "./dist/shared/validation.d.ts",
314
314
  "import": "./dist/shared/validation.js"
315
315
  },
316
+ "./testing": {
317
+ "types": "./dist/testing/index.d.ts",
318
+ "import": "./dist/testing/index.js"
319
+ },
320
+ "./testing/observe-paint.iife.js": "./dist/testing/observe-paint.iife.js",
316
321
  "./shared/theme": {
317
322
  "types": "./dist/shared/theme.d.ts",
318
323
  "import": "./dist/shared/theme.js"