@alikhalilll/a-smart-skeleton 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -186
- package/dist/_chunks/core.js +142 -15
- package/dist/_chunks/core.js.map +1 -1
- package/dist/_chunks/index.d.ts +30 -5
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/styles.css +136 -2
- package/package.json +2 -2
- package/src/core/fade.ts +3 -3
- package/src/core/index.ts +1 -1
- package/src/core/inline.generated.ts +1 -1
- package/src/core/measure.ts +117 -0
- package/src/core/plan.ts +1 -1
- package/src/core/reveals.ts +12 -3
- package/src/core/shimmer.ts +71 -15
- package/src/core/styles.ts +20 -0
- package/web-types.json +1 -1
package/dist/_chunks/index.d.ts
CHANGED
|
@@ -35,20 +35,35 @@ declare function addStyles(): void;
|
|
|
35
35
|
declare function removeStyles(): void;
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/core/inline.generated.d.ts
|
|
38
|
-
declare const INLINE_SCRIPT = "\"use strict\";(()=>{var B=\"ask-ghost\";var D=\"ask-layer\",L=\"ask-rect\";var R=\"ask-covered\",$=\"ask-own\",v=\"ask-ignore\",H=\"ask-block\",I=Symbol.for(\"a-smart-skeleton.ghost\"),G=Symbol.for(\"a-smart-skeleton.uncover\"),P=\"a-smart-skeleton.boot\";var W=\"var(--ask-base, rgb(128 128 128 / 0.2))\",z=\"var(--ask-highlight, rgb(255 255 255 / 0.12))\";var F={shimmer:{slow:4e3,fast:2e3},pulse:{slow:2400,fast:1200}},X=[\"a\",\"b\",\"code\",\"dd\",\"dt\",\"em\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"i\",\"label\",\"li\",\"p\",\"small\",\"span\",\"strong\",\"td\",\"th\",\"time\"],U=[\"audio\",\"canvas\",\"embed\",\"iframe\",\"img\",\"input\",\"object\",\"picture\",\"select\",\"svg\",\"textarea\",\"video\"];var gt,V=()=>gt??(gt=/jsdom/.test(navigator.userAgent)?null:document.createElement(\"canvas\").getContext(\"2d\"));var J=(t,n)=>t?{left:Math.max(t.left,n.left),right:Math.min(t.right,n.right),top:Math.max(t.top,n.top),bottom:Math.min(t.bottom,n.bottom)}:n,A=t=>[[t.left,t.top],[t.right,t.top],[t.right,t.bottom],[t.left,t.bottom]],k=(t,n)=>Math.abs(t[0]-n[0])<1&&Math.abs(t[1]-n[1])<1;function Q(t,n){let e=Math.min(n.right-n.left,n.bottom-n.top),o=r=>r.endsWith(\"%\")?parseFloat(r)/100*e:parseFloat(r)||0;return[o(t.borderTopLeftRadius),o(t.borderTopRightRadius),o(t.borderBottomRightRadius),o(t.borderBottomLeftRadius)]}function bt(t,n,e){let o=J(t,n),r=Q(e,n),c=t?A(t):[],a=A(n),m=A(o).map((f,T)=>k(f,a[T])?r[T]:t&&k(f,c[T])?t.corners[T]:0),{left:s,right:i,top:l,bottom:h}=o;return{left:s,right:i,top:l,bottom:h,corners:m}}function Tt(t,n,e,o){if(!t)return e;let r=A(t),c=A(n).map((m,s)=>t.corners[s]>0&&k(m,r[s]));if(!c.some(Boolean))return e;let a=Q(o,n);return c.map((m,s)=>m?Math.max(a[s],t.corners[s]):a[s]).map(m=>`${m}px`).join(\" \")}var j=(t,n)=>{let e=J(n,t);return e.right-e.left>=2&&e.bottom-e.top>=2?e:null},q={top:\"ascender\",bottom:\"descender\"},C=new Map,tt=t=>[...t.getClientRects?.()??[]];function St(t){let n=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;if(C.has(n))return C.get(n);let e=V(),o=null;if(e){e.font=n;let r=e.measureText(\"H\"),c=a=>e.measureText(a).actualBoundingBoxAscent;o={ascent:r.fontBoundingBoxAscent,descent:r.fontBoundingBoxDescent,ascender:c(\"bdfhkl\"),capHeight:r.actualBoundingBoxAscent,xHeight:c(\"xz\"),descender:e.measureText(\"gjpqy\").actualBoundingBoxDescent}}return C.set(n,o),o}var Y={ascender:\"ascender\",\"cap-height\":\"capHeight\",\"x-height\":\"xHeight\"},K=(t,n,e,o)=>{let r=t.getPropertyValue(n).trim();return e.includes(r)?r:o};function xt(t,n,e){let o=St(n);if(!o){let s=Math.min(e*.72,t.bottom-t.top),i=(t.top+t.bottom)/2;return{barTop:i-s/2,barBottom:i+s/2}}let r=K(n,\"--ask-text-top\",Object.keys(Y),q.top),c=K(n,\"--ask-text-bottom\",[\"baseline\",\"descender\"],q.bottom),a=o.ascent+o.descent,m=t.top+(t.bottom-t.top-a)/2+o.ascent;return{barTop:m-o[Y[r]],barBottom:m+(c===\"descender\"?o.descender:0)}}var Et=new Set(U),Rt=new Set(X),et=.4,At=/[,/]\\s*0\\)$/,y=(t,n)=>t!==\"\"&&t!==n,yt=[\"Top\",\"Right\",\"Bottom\",\"Left\"],Mt=t=>yt.every(n=>y(t[`border${n}Style`],\"none\")&&y(t[`border${n}Width`],\"0px\")),Ct=t=>{let[n=0,e=0,o=0,r=0]=(t.replace(/rgba?\\([^)]*\\)|#\\w+/g,\"\").match(/-?[\\d.]+px/g)??[]).map(parseFloat);return t.includes(\"inset\")&&!o&&!r&&n===0!=(e===0)&&Math.abs(n+e)<=2},kt=t=>y(t,\"none\")&&!t.split(/,(?![^(]*\\))/).every(Ct),Ot=t=>y(t.backgroundColor,\"transparent\")&&!At.test(t.backgroundColor)||y(t.backgroundImage,\"none\")||kt(t.boxShadow)||Mt(t),ot=t=>Et.has(t.localName),nt=t=>Rt.has(t.localName)&&!t.firstElementChild&&!t.textContent?.trim(),wt=t=>{let n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT),e=document.createRange(),o=[],r=0;for(;n.nextNode();){let i=n.currentNode;if(i.nodeType===Node.TEXT_NODE){let l=i.parentElement;if(!i.textContent?.trim()||!l)continue;r++;let h=l.getBoundingClientRect();if(h.width<=1||h.height<=1)continue;e.selectNodeContents(i),o.push(tt(e).filter(f=>f.width||f.height))}else nt(i)&&(r++,o.push([...i.getClientRects()]))}if(!o.some(i=>i.length))return r;let c=(parseFloat(getComputedStyle(t).fontSize)||16)*et,a=(i,l)=>Math.min(i.bottom,l.bottom)-Math.max(i.top,l.top)>=Math.min(i.height,l.height)/2&&Math.max(i.left,l.left)-Math.min(i.right,l.right)<=c,m=o.map((i,l)=>l),s=i=>m[i]===i?i:m[i]=s(m[i]);for(let i=0;i<o.length;i++)for(let l=i+1;l<o.length;l++)o[i].some(h=>o[l].some(f=>a(h,f)))&&(m[s(l)]=s(i));return new Set(o.map((i,l)=>s(l))).size},Nt=(t,n)=>t.hasAttribute(H)||ot(t)||Ot(n)&&wt(t)<=1;function _t(t,n){if(parseFloat(n.borderRadius)||!t.parentElement)return n.borderRadius||\"0px\";let e=t.parentElement,o=getComputedStyle(e),r=t.getBoundingClientRect(),c=e.getBoundingClientRect();return Math.abs(r.width-c.width)<1&&Math.abs(r.height-c.height)<1&&o.overflow!==\"visible\"?o.borderRadius:n.borderRadius||\"0px\"}function Z(t){t.sort((e,o)=>e.left-o.left);let n=[];for(let e of t){let o=n.find(r=>{let c=Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top),a=Math.min(r.bottom-r.top,e.bottom-e.top),m=e.left-r.right;return c>=a/2&&m<=Math.max(r.fontSize,e.fontSize)*et});o?(o.left=Math.min(o.left,e.left),o.right=Math.max(o.right,e.right),o.top=Math.min(o.top,e.top),o.bottom=Math.max(o.bottom,e.bottom),o.fontSize=Math.max(o.fontSize,e.fontSize),o.barTop=Math.min(o.barTop,e.barTop),o.barBottom=Math.max(o.barBottom,e.barBottom)):n.push({...e})}return n.map(e=>{let o=e.barBottom-e.barTop;return{x:e.left,y:e.barTop,width:e.right-e.left,height:o,radius:e.radius||`${Math.round(o/3)}px`}})}function rt(t,n,{mark:e=!0,onCovered:o}={}){let r=n.getBoundingClientRect(),c=n.offsetWidth?r.width/n.offsetWidth:1,a=n.offsetHeight?r.height/n.offsetHeight:1,m=d=>({left:(d.left-r.left)/c,right:(d.right-r.left)/c,top:(d.top-r.top)/a,bottom:(d.bottom-r.top)/a}),s=[],i=[],l=new Set,h=document.createRange(),f=(d,g,b)=>{let u=j(d,b);if(!u)return;let p=parseFloat(g.fontSize)||16,M=m(u);i.push({...M,fontSize:p,...xt(M,g,p),radius:g.getPropertyValue(\"--ask-radius\").trim()})},T=(d,g)=>{let b=d.data.search(/\\S/);if(b<0||!d.parentElement)return;h.setStart(d,b),h.setEnd(d,d.data.trimEnd().length);let u=getComputedStyle(d.parentElement);for(let p of tt(h))f(p,u,g)},_=(d,g)=>{for(let b of d.childNodes){if(b.nodeType===Node.TEXT_NODE){T(b,g);continue}if(b.nodeType!==Node.ELEMENT_NODE)continue;let u=b;if(u.hasAttribute(v)||u.hasAttribute($))continue;let p=getComputedStyle(u);if(p.display===\"none\")continue;if(Nt(u,p)){let E=j(u.getBoundingClientRect(),g);if(E){let S=m(E);s.push({x:S.left,y:S.top,width:S.right-S.left,height:S.bottom-S.top,radius:Tt(g,E,_t(u,p),p)})}ot(u)||l.add(u);continue}if(nt(u)){for(let E of u.getClientRects())f(E,p,g);continue}let M=p.overflowX!==\"visible\"||p.overflowY!==\"visible\";_(u,M?bt(g,u.getBoundingClientRect(),p):g)}};if(_(t,null),o?.(l),!e)return[...s,...Z(i)];for(let d of t.querySelectorAll(`[${R}]`))l.has(d)||d.removeAttribute(R);for(let d of l)d.hasAttribute(R)||d.setAttribute(R,\"\");return[...s,...Z(i)]}var Bt=t=>typeof matchMedia<\"u\"&&matchMedia(t).matches,Dt=()=>typeof Element<\"u\"&&typeof Element.prototype.animate==\"function\",st=()=>!Dt()||Bt(\"(prefers-reduced-motion: reduce)\");var it=t=>t.getAnimations?.()??[];var Lt=.7,$t=1280,at=320,vt=2.5,Ht=.45,It=[\"shimmer\",\"group-shimmer\",\"pulse\",\"none\"];function mt(t){let n=getComputedStyle(t),e=(c,a,m)=>{let s=n.getPropertyValue(c).trim();return a.includes(s)?s:m},o=e(\"--ask-animation\",It,\"shimmer\"),r=e(\"--ask-speed\",[\"slow\",\"fast\"],\"slow\");return{animation:o,duration:F[o===\"pulse\"?\"pulse\":\"shimmer\"][r]}}var w=20,Gt=Math.sin(w*Math.PI/180),lt=Math.cos(w*Math.PI/180),Pt=Gt/lt;var Wt=`${90+w}deg`,O=.85,x=12,ct=t=>(1-Math.cos(Math.PI*t))/2;function zt(t){let n=t*vt,e=(r,c)=>`color-mix(in srgb, ${z} ${(c*100).toFixed(1)}%, transparent) ${(r*t).toFixed(2)}px`,o=[];for(let r=0;r<=x;r++)o.push(e(r/x*O,ct(r/x)));for(let r=1;r<=x;r++)o.push(e(O+r/x*(1-O),ct(1-r/x)));return{width:n/lt,image:`repeating-linear-gradient(${Wt}, ${o.join(\", \")}, transparent ${n.toFixed(2)}px)`}}function Ft(t,n,e=mt(t)){for(let f of it(t))f.cancel();if(t.style.backgroundImage=\"\",t.style.backgroundRepeat=\"\",st()||typeof t.animate!=\"function\"||e.animation===\"none\")return;let o={duration:e.duration,iterations:1/0};if(e.animation===\"pulse\"){t.animate([{opacity:1,easing:\"ease-in-out\"},{opacity:Ht,easing:\"ease-in-out\"},{opacity:1}],o).startTime=0;return}let r=t.getBoundingClientRect(),c=r.left+scrollX,a=e.animation===\"group-shimmer\"?n??{left:c,top:r.top,width:r.width,height:r.height}:{left:0,top:0,width:document.documentElement.clientWidth||innerWidth,height:innerHeight},m=Math.min(Math.max(a.width*.4,80),at),{width:s,image:i}=zt(m),l=c-a.left+(r.top-a.top)*Pt,h=e.duration*Lt/($t+at);t.style.backgroundImage=i,t.style.backgroundSize=`${s}px 100%`,t.style.backgroundRepeat=\"repeat-x\",t.animate([{backgroundPosition:`${-l}px 0`},{backgroundPosition:`${s-l}px 0`}],{duration:s*h,iterations:1/0}).startTime=0}var Xt=t=>t.shadowRoot??t.attachShadow({mode:\"open\"});function dt(t,n){let e=Xt(t),o=t.getBoundingClientRect(),r={left:o.left+scrollX,top:o.top,width:o.width,height:o.height},c=mt(t);for(n.forEach((a,m)=>{let s=e.children[m];s||(s=document.createElement(\"div\"),s.setAttribute(L,\"\"),s.style.cssText=`position:absolute;display:block;pointer-events:none;background-color:${W};background-repeat:no-repeat`,e.append(s)),Object.assign(s.style,{left:`${a.x}px`,top:`${a.y}px`,width:`${a.width}px`,height:`${a.height}px`,borderRadius:a.radius});let i=`${Math.round(r.left+a.x)}|${Math.round(a.y)}|${Math.round(a.height)}|${Math.round(r.left)}|${Math.round(r.width)}|${Math.round(r.height)}|${document.documentElement.clientWidth}|${c.animation}|${c.duration}`;s.dataset.motion!==i&&(s.dataset.motion=i,Ft(s,r,c))});e.children.length>n.length;)e.lastElementChild.remove()}var pt=t=>t.parentElement?`${pt(t.parentElement)} > :nth-child(${[...t.parentElement.children].indexOf(t)+1})`:\":root\";function N(t){let n=t?.previousElementSibling,e=n?.querySelector(`:scope > [${B}]`),o=n?.querySelector(`:scope > [${D}]`);if(!n||!e||!o)return;let r=typeof CSSStyleSheet==\"function\"&&\"replaceSync\"in CSSStyleSheet.prototype?new CSSStyleSheet:null;r&&(document.adoptedStyleSheets=[...document.adoptedStyleSheets,r],n[G]=()=>{document.adoptedStyleSheets=document.adoptedStyleSheets.filter(s=>s!==r)});let c=s=>r?.replaceSync(s.size?`${[...s].map(pt).join(\", \")} { visibility: hidden !important; }`:\"\"),a=()=>{if(!o.isConnected||n[I])return m.disconnect();e.getClientRects().length&&dt(o,rt(e,o,{mark:!1,onCovered:c}))},m=new ResizeObserver(a);m.observe(n),document.fonts?.ready.then(a)}var ht=self,ft=Symbol.for(P),ut=ht[ft];ht[ft]=N;Array.isArray(ut)&&ut.forEach(N);N(document.currentScript);})();";
|
|
38
|
+
declare const INLINE_SCRIPT = "\"use strict\";(()=>{var H=\"ask-ghost\";var G=\"ask-layer\",M=\"ask-rect\";var A=\"ask-covered\",P=\"ask-own\",W=\"ask-ignore\",F=\"ask-block\",z=Symbol.for(\"a-smart-skeleton.ghost\"),U=Symbol.for(\"a-smart-skeleton.uncover\"),X=\"a-smart-skeleton.boot\";var j=\"var(--ask-highlight, rgb(255 255 255 / 0.12))\";var V={shimmer:{slow:4e3,fast:2e3},pulse:{slow:2400,fast:1200}},q=[\"a\",\"b\",\"code\",\"dd\",\"dt\",\"em\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"i\",\"label\",\"li\",\"p\",\"small\",\"span\",\"strong\",\"td\",\"th\",\"time\"],Y=[\"audio\",\"canvas\",\"embed\",\"iframe\",\"img\",\"input\",\"object\",\"picture\",\"select\",\"svg\",\"textarea\",\"video\"];var Et,K=()=>Et??(Et=/jsdom/.test(navigator.userAgent)?null:document.createElement(\"canvas\").getContext(\"2d\"));var nt=(t,e)=>t?{left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}:e,k=t=>[[t.left,t.top],[t.right,t.top],[t.right,t.bottom],[t.left,t.bottom]],$=(t,e)=>Math.abs(t[0]-e[0])<1&&Math.abs(t[1]-e[1])<1;function rt(t,e){let r=Math.min(e.right-e.left,e.bottom-e.top),o=n=>n.endsWith(\"%\")?parseFloat(n)/100*r:parseFloat(n)||0;return[o(t.borderTopLeftRadius),o(t.borderTopRightRadius),o(t.borderBottomRightRadius),o(t.borderBottomLeftRadius)]}function At(t,e,r){let o=nt(t,e),n=rt(r,e),c=t?k(t):[],i=k(e),l=k(o).map((b,R)=>$(b,i[R])?n[R]:t&&$(b,c[R])?t.corners[R]:0),{left:s,right:a,top:d,bottom:h}=o;return{left:s,right:a,top:d,bottom:h,corners:l}}function Z(t,e,r,o){if(!t)return r;let n=k(t),c=k(e).map((l,s)=>t.corners[s]>0&&$(l,n[s]));if(!c.some(Boolean))return r;let i=rt(o,e);return c.map((l,s)=>l?Math.max(i[s],t.corners[s]):i[s]).map(l=>`${l}px`).join(\" \")}var O=(t,e)=>{let r=nt(e,t);return r.right-r.left>=2&&r.bottom-r.top>=2?r:null},J={top:\"ascender\",bottom:\"descender\"},w=new Map,st=t=>[...t.getClientRects?.()??[]];function kt(t){let e=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;if(w.has(e))return w.get(e);let r=K(),o=null;if(r){r.font=e;let n=r.measureText(\"H\"),c=i=>r.measureText(i).actualBoundingBoxAscent;o={ascent:n.fontBoundingBoxAscent,descent:n.fontBoundingBoxDescent,ascender:c(\"bdfhkl\"),capHeight:n.actualBoundingBoxAscent,xHeight:c(\"xz\"),descender:r.measureText(\"gjpqy\").actualBoundingBoxDescent}}return w.set(e,o),o}var Q={ascender:\"ascender\",\"cap-height\":\"capHeight\",\"x-height\":\"xHeight\"},tt=(t,e,r,o)=>{let n=t.getPropertyValue(e).trim();return r.includes(n)?n:o};function Ct(t,e,r){let o=kt(e);if(!o){let s=Math.min(r*.72,t.bottom-t.top),a=(t.top+t.bottom)/2;return{barTop:a-s/2,barBottom:a+s/2}}let n=tt(e,\"--ask-text-top\",Object.keys(Q),J.top),c=tt(e,\"--ask-text-bottom\",[\"baseline\",\"descender\"],J.bottom),i=o.ascent+o.descent,l=t.top+(t.bottom-t.top-i)/2+o.ascent;return{barTop:l-o[Q[n]],barBottom:l+(c===\"descender\"?o.descender:0)}}var Mt=new Set(Y),Ot=new Set(q),it=.4,at=/[,/]\\s*0\\)$/,g=(t,e)=>t!==\"\"&&t!==e,N=[\"Top\",\"Right\",\"Bottom\",\"Left\"],wt=t=>N.every(e=>g(t[`border${e}Style`],\"none\")&&g(t[`border${e}Width`],\"0px\")),$t=t=>N.some(e=>g(t[`border${e}Style`],\"none\")&&g(t[`border${e}Width`],\"0px\")),Bt=t=>{let[e=0,r=0,o=0,n=0]=(t.replace(/rgba?\\([^)]*\\)|#\\w+/g,\"\").match(/-?[\\d.]+px/g)??[]).map(parseFloat);return t.includes(\"inset\")&&!o&&!n&&e===0!=(r===0)&&Math.abs(e+r)<=2},ct=t=>g(t,\"none\")&&!t.split(/,(?![^(]*\\))/).every(Bt);function Nt(t){let e=[],r=0,o=0;for(let n=0;n<t.length;n++){let c=t[n];c===\"(\"?r++:c===\")\"?r--:c===\",\"&&r===0&&(e.push(t.slice(o,n)),o=n+1)}return e.push(t.slice(o)),e.map(n=>n.trim()).filter(n=>n&&!n.startsWith(\"url(\")).join(\", \")}var dt=t=>g(t.backgroundColor,\"transparent\")&&!at.test(t.backgroundColor)||g(t.backgroundImage,\"none\")||ct(t.boxShadow)||wt(t);function _t(t){let e={},r=t.backgroundColor;g(r,\"transparent\")&&!at.test(r)&&(e.background=r);let o=t.backgroundImage;if(g(o,\"none\")){let n=Nt(o);n&&(e.background=e.background?`${n}, ${e.background}`:n)}for(let n of N){let c=t[`border${n}Width`],i=t[`border${n}Style`],l=t[`border${n}Color`];if(g(i,\"none\")&&g(c,\"0px\")&&parseFloat(c)>0){let s=`border${n}`;e[s]=`${c} ${i} ${l}`}}return ct(t.boxShadow)&&(e.boxShadow=t.boxShadow),Object.keys(e).length?e:void 0}var B=t=>Mt.has(t.localName),lt=t=>Ot.has(t.localName)&&!t.firstElementChild&&!t.textContent?.trim(),Dt=t=>{let e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT),r=document.createRange(),o=[],n=0;for(;e.nextNode();){let a=e.currentNode;if(a.nodeType===Node.TEXT_NODE){let d=a.parentElement;if(!a.textContent?.trim()||!d)continue;n++;let h=d.getBoundingClientRect();if(h.width<=1||h.height<=1)continue;r.selectNodeContents(a),o.push(st(r).filter(b=>b.width||b.height))}else lt(a)&&(n++,o.push([...a.getClientRects()]))}if(!o.some(a=>a.length))return n;let c=(parseFloat(getComputedStyle(t).fontSize)||16)*it,i=(a,d)=>Math.min(a.bottom,d.bottom)-Math.max(a.top,d.top)>=Math.min(a.height,d.height)/2&&Math.max(a.left,d.left)-Math.min(a.right,d.right)<=c,l=o.map((a,d)=>d),s=a=>l[a]===a?a:l[a]=s(l[a]);for(let a=0;a<o.length;a++)for(let d=a+1;d<o.length;d++)o[a].some(h=>o[d].some(b=>i(h,b)))&&(l[s(d)]=s(a));return new Set(o.map((a,d)=>s(d))).size},Lt=(t,e)=>t.hasAttribute(F)||B(t)||dt(e)&&Dt(t)<=1;function et(t,e){if(parseFloat(e.borderRadius)||!t.parentElement)return e.borderRadius||\"0px\";let r=t.parentElement,o=getComputedStyle(r),n=t.getBoundingClientRect(),c=r.getBoundingClientRect();return Math.abs(n.width-c.width)<1&&Math.abs(n.height-c.height)<1&&o.overflow!==\"visible\"?o.borderRadius:e.borderRadius||\"0px\"}function ot(t){t.sort((r,o)=>r.left-o.left);let e=[];for(let r of t){let o=e.find(n=>{let c=Math.min(n.bottom,r.bottom)-Math.max(n.top,r.top),i=Math.min(n.bottom-n.top,r.bottom-r.top),l=r.left-n.right;return c>=i/2&&l<=Math.max(n.fontSize,r.fontSize)*it});o?(o.left=Math.min(o.left,r.left),o.right=Math.max(o.right,r.right),o.top=Math.min(o.top,r.top),o.bottom=Math.max(o.bottom,r.bottom),o.fontSize=Math.max(o.fontSize,r.fontSize),o.barTop=Math.min(o.barTop,r.barTop),o.barBottom=Math.max(o.barBottom,r.barBottom)):e.push({...r})}return e.map(r=>{let o=r.barBottom-r.barTop;return{type:\"text\",x:r.left,y:r.barTop,width:r.right-r.left,height:o,radius:r.radius||`${Math.round(o/3)}px`}})}function mt(t,e,{mark:r=!0,onCovered:o}={}){let n=e.getBoundingClientRect(),c=e.offsetWidth?n.width/e.offsetWidth:1,i=e.offsetHeight?n.height/e.offsetHeight:1,l=m=>({left:(m.left-n.left)/c,right:(m.right-n.left)/c,top:(m.top-n.top)/i,bottom:(m.bottom-n.top)/i}),s=[],a=[],d=new Set,h=document.createRange(),b=(m,f,T)=>{let u=O(m,T);if(!u)return;let p=parseFloat(f.fontSize)||16,C=l(u);a.push({...C,fontSize:p,...Ct(C,f,p),radius:f.getPropertyValue(\"--ask-radius\").trim()})},R=(m,f)=>{let T=m.data.search(/\\S/);if(T<0||!m.parentElement)return;h.setStart(m,T),h.setEnd(m,m.data.trimEnd().length);let u=getComputedStyle(m.parentElement);for(let p of st(h))b(p,u,f)},I=(m,f)=>{for(let T of m.childNodes){if(T.nodeType===Node.TEXT_NODE){R(T,f);continue}if(T.nodeType!==Node.ELEMENT_NODE)continue;let u=T;if(u.hasAttribute(W)||u.hasAttribute(P))continue;let p=getComputedStyle(u);if(p.display===\"none\")continue;if(Lt(u,p)){let x=O(u.getBoundingClientRect(),f);if(x){let S=l(x);s.push({type:B(u)?\"media\":\"box\",x:S.left,y:S.top,width:S.right-S.left,height:S.bottom-S.top,radius:Z(f,x,et(u,p),p)})}B(u)||d.add(u);continue}if(lt(u)){for(let x of u.getClientRects())b(x,p,f);continue}if(dt(p)||$t(p)){let x=_t(p);if(x){let S=O(u.getBoundingClientRect(),f);if(S){let y=l(S);s.push({type:\"chrome\",x:y.left,y:y.top,width:y.right-y.left,height:y.bottom-y.top,radius:Z(f,S,et(u,p),p),chrome:x})}}}let C=p.overflowX!==\"visible\"||p.overflowY!==\"visible\";I(u,C?At(f,u.getBoundingClientRect(),p):f)}};if(I(t,null),o?.(d),!r)return[...s,...ot(a)];for(let m of t.querySelectorAll(`[${A}]`))d.has(m)||m.removeAttribute(A);for(let m of d)m.hasAttribute(A)||m.setAttribute(A,\"\");return[...s,...ot(a)]}var vt=t=>typeof matchMedia<\"u\"&&matchMedia(t).matches,It=()=>typeof Element<\"u\"&&typeof Element.prototype.animate==\"function\",ut=()=>!It()||vt(\"(prefers-reduced-motion: reduce)\");var _=t=>t.getAnimations?.()??[];var Ht=.7,Gt=1280,pt=320,Pt=2.5,Wt=.45,Ft=[\"shimmer\",\"group-shimmer\",\"pulse\",\"none\"];function bt(t){let e=getComputedStyle(t),r=(c,i,l)=>{let s=e.getPropertyValue(c).trim();return i.includes(s)?s:l},o=r(\"--ask-animation\",Ft,\"shimmer\"),n=r(\"--ask-speed\",[\"slow\",\"fast\"],\"slow\");return{animation:o,duration:V[o===\"pulse\"?\"pulse\":\"shimmer\"][n]}}var L=20,zt=Math.sin(L*Math.PI/180),gt=Math.cos(L*Math.PI/180),Ut=zt/gt;var Xt=`${90+L}deg`,D=.85,E=12,ht=t=>(1-Math.cos(Math.PI*t))/2;function jt(t){let e=t*Pt,r=(n,c)=>`color-mix(in srgb, ${j} ${(c*100).toFixed(1)}%, transparent) ${(n*t).toFixed(2)}px`,o=[];for(let n=0;n<=E;n++)o.push(r(n/E*D,ht(n/E)));for(let n=1;n<=E;n++)o.push(r(D+n/E*(1-D),ht(1-n/E)));return{width:e/gt,image:`repeating-linear-gradient(${Xt}, ${o.join(\", \")}, transparent ${e.toFixed(2)}px)`}}function Vt(t,e,r=bt(t)){for(let b of _(t))b.cancel();if(t.style.backgroundImage=\"\",t.style.backgroundRepeat=\"\",ut()||typeof t.animate!=\"function\"||r.animation===\"none\")return;let o={duration:r.duration,iterations:1/0};if(r.animation===\"pulse\"){t.animate([{opacity:1,easing:\"ease-in-out\"},{opacity:Wt,easing:\"ease-in-out\"},{opacity:1}],o).startTime=0;return}let n=t.getBoundingClientRect(),c=n.left+scrollX,i=r.animation===\"group-shimmer\"?e??{left:c,top:n.top,width:n.width,height:n.height}:{left:0,top:0,width:document.documentElement.clientWidth||innerWidth,height:innerHeight},l=Math.min(Math.max(i.width*.4,80),pt),{width:s,image:a}=jt(l),d=c-i.left+(n.top-i.top)*Ut,h=r.duration*Ht/(Gt+pt);t.style.backgroundImage=a,t.style.backgroundSize=`${s}px 100%`,t.style.backgroundRepeat=\"repeat-x\",t.animate([{backgroundPosition:`${-d}px 0`},{backgroundPosition:`${s-d}px 0`}],{duration:s*h,iterations:1/0}).startTime=0}var qt=t=>[...t.querySelectorAll(`:scope > [${M}]`)],ft=4,Yt=t=>t.replace(/(\\d+(?:\\.\\d+)?)px/g,(e,r)=>{let o=parseFloat(r);return Number.isFinite(o)&&o<ft?`${ft}px`:`${o}px`});function St(t,e){let r=qt(t),o=t.getBoundingClientRect(),n={left:o.left+scrollX,top:o.top,width:o.width,height:o.height},c=bt(t);e.forEach((i,l)=>{let s=r[l];if(s||(s=document.createElement(\"div\"),s.style.cssText=\"position:absolute;display:block;pointer-events:none;background-repeat:no-repeat\",t.append(s)),s.setAttribute(M,i.type),Object.assign(s.style,{left:`${i.x}px`,top:`${i.y}px`,width:`${i.width}px`,height:`${i.height}px`,borderRadius:i.type===\"chrome\"?i.radius:Yt(i.radius)}),i.type===\"chrome\"){for(let h of _(s))h.cancel();s.style.backgroundImage=\"\",s.style.backgroundSize=\"\",s.style.backgroundRepeat=\"\";let d=i.chrome;s.style.background=d?.background??\"\",s.style.borderTop=d?.borderTop??\"\",s.style.borderRight=d?.borderRight??\"\",s.style.borderBottom=d?.borderBottom??\"\",s.style.borderLeft=d?.borderLeft??\"\",s.style.boxShadow=d?.boxShadow??\"\",s.dataset.motion=\"chrome\";return}s.dataset.motion===\"chrome\"&&(s.style.background=\"\",s.style.borderTop=\"\",s.style.borderRight=\"\",s.style.borderBottom=\"\",s.style.borderLeft=\"\",s.style.boxShadow=\"\");let a=`${Math.round(n.left+i.x)}|${Math.round(i.y)}|${Math.round(i.height)}|${Math.round(n.left)}|${Math.round(n.width)}|${Math.round(n.height)}|${document.documentElement.clientWidth}|${c.animation}|${c.duration}`;s.dataset.motion!==a&&(s.dataset.motion=a,Vt(s,n,c))});for(let i=r.length-1;i>=e.length;i--)r[i].remove()}var xt=t=>t.parentElement?`${xt(t.parentElement)} > :nth-child(${[...t.parentElement.children].indexOf(t)+1})`:\":root\";function v(t){let e=t?.previousElementSibling,r=e?.querySelector(`:scope > [${H}]`),o=e?.querySelector(`:scope > [${G}]`);if(!e||!r||!o)return;let n=typeof CSSStyleSheet==\"function\"&&\"replaceSync\"in CSSStyleSheet.prototype?new CSSStyleSheet:null;n&&(document.adoptedStyleSheets=[...document.adoptedStyleSheets,n],e[U]=()=>{document.adoptedStyleSheets=document.adoptedStyleSheets.filter(s=>s!==n)});let c=s=>n?.replaceSync(s.size?`${[...s].map(xt).join(\", \")} { visibility: hidden !important; }`:\"\"),i=()=>{if(!o.isConnected||e[z])return l.disconnect();r.getClientRects().length&&St(o,mt(r,o,{mark:!1,onCovered:c}))},l=new ResizeObserver(i);l.observe(e),document.fonts?.ready.then(i)}var Rt=self,yt=Symbol.for(X),Tt=Rt[yt];Rt[yt]=v;Array.isArray(Tt)&&Tt.forEach(v);v(document.currentScript);})();";
|
|
39
39
|
/** For every skeleton after a page's first: calls the boot INLINE_SCRIPT left on window. */
|
|
40
40
|
declare const INLINE_STUB = "(s=>{let k=Symbol.for(\"a-smart-skeleton.boot\"),b=self[k];typeof b==\"function\"?b(s):(self[k]=b||[]).push(s)})(document.currentScript)";
|
|
41
41
|
/** Either, as a whole element — for templates where a literal script tag would be read as the component's own. */
|
|
42
42
|
declare const inlineScriptTag: (nonce?: string, stub?: boolean) => string;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/core/measure.d.ts
|
|
45
|
+
/** Captured paint from a container — background / borders / box-shadow — reproduced on
|
|
46
|
+
* the chrome bone so the outline survives shape recall from storage, SSR pre-paint, and
|
|
47
|
+
* any path where the real DOM isn't visible under the layer. */
|
|
48
|
+
type SkeletonChrome = {
|
|
49
|
+
background?: string;
|
|
50
|
+
borderTop?: string;
|
|
51
|
+
borderRight?: string;
|
|
52
|
+
borderBottom?: string;
|
|
53
|
+
borderLeft?: string;
|
|
54
|
+
boxShadow?: string;
|
|
55
|
+
};
|
|
45
56
|
/** A box to draw, relative to the layer it was measured against. */
|
|
46
57
|
type SkeletonRect = {
|
|
58
|
+
/** Which kind of leaf this bone stands in for — exposed as `[ask-rect="<type>"]` so
|
|
59
|
+
* consumers can style text / media / box / chrome bones differently in their own CSS. */
|
|
60
|
+
type: 'text' | 'media' | 'box' | 'chrome';
|
|
47
61
|
x: number;
|
|
48
62
|
y: number;
|
|
49
63
|
width: number;
|
|
50
64
|
height: number;
|
|
51
|
-
radius: string;
|
|
65
|
+
radius: string; /** Present on `type === 'chrome'` bones — the container's own paint, captured verbatim from `getComputedStyle`. */
|
|
66
|
+
chrome?: SkeletonChrome;
|
|
52
67
|
};
|
|
53
68
|
/** The font line each line of text is drawn from. */
|
|
54
69
|
type TextTop = 'ascender' | 'cap-height' | 'x-height';
|
|
@@ -163,7 +178,17 @@ type Span = {
|
|
|
163
178
|
declare function shimmer(element: HTMLElement, group?: Span, motion?: Motion): void;
|
|
164
179
|
/** The rect elements drawn into `layer`. */
|
|
165
180
|
declare const rectsOf: (layer: Element) => HTMLElement[];
|
|
166
|
-
/** Draws `rects` into `layer`, reusing the elements already there.
|
|
181
|
+
/** Draws `rects` into `layer`, reusing the elements already there.
|
|
182
|
+
*
|
|
183
|
+
* Bones live in the light DOM (not a shadow root) so a consumer's stylesheet
|
|
184
|
+
* can reach them — selectors like `[ask-rect="text"]`, `[ask-rect="media"]`,
|
|
185
|
+
* `[ask-rect="box"]`, or the `--ask-base` / `--ask-highlight` custom
|
|
186
|
+
* properties — and theme the skeleton with the consumer's own tokens rather
|
|
187
|
+
* than plugin defaults. Positioning (x/y/width/height/radius) stays inline
|
|
188
|
+
* because it is per-bone; fill colour comes from the stylesheet.
|
|
189
|
+
*
|
|
190
|
+
* Added after mount, so Vue/React hydration never sees them.
|
|
191
|
+
*/
|
|
167
192
|
declare function drawSkeleton(layer: HTMLElement, rects: SkeletonRect[]): void;
|
|
168
193
|
//#endregion
|
|
169
194
|
//#region src/core/ghost.d.ts
|
|
@@ -296,7 +321,7 @@ type RevealSpec = {
|
|
|
296
321
|
choose?: (context: RevealContext) => RevealSpec;
|
|
297
322
|
};
|
|
298
323
|
/** A built-in reveal by name, or one of your own. */
|
|
299
|
-
type RevealMode = 'together' | 'sequence' | 'smart' | 'sweep' | RevealSpec;
|
|
324
|
+
type RevealMode = 'together' | 'sequence' | 'smart' | 'sweep' | 'instant' | RevealSpec;
|
|
300
325
|
declare const SKELETON_DELAY = 150;
|
|
301
326
|
type SequencePlan = {
|
|
302
327
|
kind: 'sequence'; /** When a piece of content appears; null to appear at once. */
|
|
@@ -402,5 +427,5 @@ declare class Reveal {
|
|
|
402
427
|
destroy(): void;
|
|
403
428
|
}
|
|
404
429
|
//#endregion
|
|
405
|
-
export { skeletonCSS as $, createSkeletonBox as A,
|
|
430
|
+
export { skeletonCSS as $, createSkeletonBox as A, FADE_DURATION as At, shimmer as B, quickly as C, ATTR_RECT as Ct, prefersReducedMotion as D, ATTR_XRAY as Dt, together as E, ATTR_STATUS as Et, Ghost as F, DEFAULT_THEME as G, debugging as H, GhostOptions as I, SkeletonMode as J, SkeletonAnimation as K, drawSkeleton as L, forgetShapes as M, RESIZE_DURATION as Mt, Memory as N, DEFAULT_SKELETON_BOX_OPTIONS as O, CASCADE_SPREAD as Ot, MemoryOptions as P, applyTheme as Q, motionOf as R, planReveal as S, ATTR_PANE as St, smart as T, ATTR_SNAPSHOT as Tt, setDebug as U, checkNonce as V, DEFAULT_COLORS as W, SkeletonText as X, SkeletonSpeed as Y, SkeletonTheme as Z, WipePane as _, ATTR_GHOST as _t, exitDuration as a, TextBottom as at, byRow as b, ATTR_LOADING as bt, boxOf as c, INLINE_SCRIPT as ct, Piece as d, SMART_SKELETON_CSS as dt, themeStyleTag as et, RevealContext as f, addStyles as ft, Wipe as g, ATTR_DEBUG as gt, SKELETON_DELAY as h, ATTR_BLOCK as ht, pendingImages as i, SkeletonRect as it, skeletonBoxStyle as j, IMAGE_TIMEOUT as jt, SkeletonBoxOptions as k, DURATIONS as kt, fadeIn as l, INLINE_STUB as lt, RevealSpec as m, ATTR_BAR as mt, RevealOptions as n, DEFAULT_TEXT as nt, sweep as o, TextTop as ot, RevealMode as p, removeStyles as pt, SkeletonColors as q, imageReady as r, SkeletonChrome as rt, PaneBox as s, measureSkeleton as st, Reveal as t, themeVariables as tt, fadeOut as u, inlineScriptTag as ut, byContent as v, ATTR_IGNORE as vt, sequence as w, ATTR_REVEAL as wt, instant as x, ATTR_OWN as xt, byPosition as y, ATTR_LAYER as yt, rectsOf as z };
|
|
406
431
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as skeletonCSS, A as createSkeletonBox, At as
|
|
2
|
-
export { ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together };
|
|
1
|
+
import { $ as skeletonCSS, A as createSkeletonBox, At as FADE_DURATION, B as shimmer, C as quickly, Ct as ATTR_RECT, D as prefersReducedMotion, Dt as ATTR_XRAY, E as together, Et as ATTR_STATUS, F as Ghost, G as DEFAULT_THEME, H as debugging, I as GhostOptions, J as SkeletonMode, K as SkeletonAnimation, L as drawSkeleton, M as forgetShapes, Mt as RESIZE_DURATION, N as Memory, O as DEFAULT_SKELETON_BOX_OPTIONS, Ot as CASCADE_SPREAD, P as MemoryOptions, Q as applyTheme, R as motionOf, S as planReveal, St as ATTR_PANE, T as smart, Tt as ATTR_SNAPSHOT, U as setDebug, V as checkNonce, W as DEFAULT_COLORS, X as SkeletonText, Y as SkeletonSpeed, Z as SkeletonTheme, _ as WipePane, _t as ATTR_GHOST, a as exitDuration, at as TextBottom, b as byRow, bt as ATTR_LOADING, c as boxOf, ct as INLINE_SCRIPT, d as Piece, dt as SMART_SKELETON_CSS, et as themeStyleTag, f as RevealContext, ft as addStyles, g as Wipe, gt as ATTR_DEBUG, h as SKELETON_DELAY, ht as ATTR_BLOCK, i as pendingImages, it as SkeletonRect, j as skeletonBoxStyle, jt as IMAGE_TIMEOUT, k as SkeletonBoxOptions, kt as DURATIONS, l as fadeIn, lt as INLINE_STUB, m as RevealSpec, mt as ATTR_BAR, n as RevealOptions, nt as DEFAULT_TEXT, o as sweep, ot as TextTop, p as RevealMode, pt as removeStyles, q as SkeletonColors, r as imageReady, rt as SkeletonChrome, s as PaneBox, st as measureSkeleton, t as Reveal, tt as themeVariables, u as fadeOut, ut as inlineScriptTag, v as byContent, vt as ATTR_IGNORE, w as sequence, wt as ATTR_REVEAL, x as instant, xt as ATTR_OWN, y as byPosition, yt as ATTR_LAYER, z as rectsOf } from "../_chunks/index.js";
|
|
2
|
+
export { ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonChrome, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as skeletonCSS, A as createSkeletonBox, At as
|
|
2
|
-
export { ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together };
|
|
1
|
+
import { $ as skeletonCSS, A as createSkeletonBox, At as FADE_DURATION, B as shimmer, C as quickly, Ct as ATTR_RECT, D as prefersReducedMotion, Dt as ATTR_XRAY, E as together, Et as ATTR_STATUS, F as Ghost, G as DEFAULT_THEME, H as debugging, I as GhostOptions, J as SkeletonMode, K as SkeletonAnimation, L as drawSkeleton, M as forgetShapes, Mt as RESIZE_DURATION, N as Memory, O as DEFAULT_SKELETON_BOX_OPTIONS, Ot as CASCADE_SPREAD, P as MemoryOptions, Q as applyTheme, R as motionOf, S as planReveal, St as ATTR_PANE, T as smart, Tt as ATTR_SNAPSHOT, U as setDebug, V as checkNonce, W as DEFAULT_COLORS, X as SkeletonText, Y as SkeletonSpeed, Z as SkeletonTheme, _ as WipePane, _t as ATTR_GHOST, a as exitDuration, at as TextBottom, b as byRow, bt as ATTR_LOADING, c as boxOf, ct as INLINE_SCRIPT, d as Piece, dt as SMART_SKELETON_CSS, et as themeStyleTag, f as RevealContext, ft as addStyles, g as Wipe, gt as ATTR_DEBUG, h as SKELETON_DELAY, ht as ATTR_BLOCK, i as pendingImages, it as SkeletonRect, j as skeletonBoxStyle, jt as IMAGE_TIMEOUT, k as SkeletonBoxOptions, kt as DURATIONS, l as fadeIn, lt as INLINE_STUB, m as RevealSpec, mt as ATTR_BAR, n as RevealOptions, nt as DEFAULT_TEXT, o as sweep, ot as TextTop, p as RevealMode, pt as removeStyles, q as SkeletonColors, r as imageReady, rt as SkeletonChrome, s as PaneBox, st as measureSkeleton, t as Reveal, tt as themeVariables, u as fadeOut, ut as inlineScriptTag, v as byContent, vt as ATTR_IGNORE, w as sequence, wt as ATTR_REVEAL, x as instant, xt as ATTR_OWN, y as byPosition, yt as ATTR_LAYER, z as rectsOf } from "../_chunks/index.js";
|
|
2
|
+
export { ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonChrome, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as skeletonCSS, A as createSkeletonBox, At as
|
|
1
|
+
import { $ as skeletonCSS, A as createSkeletonBox, At as FADE_DURATION, B as shimmer, C as quickly, Ct as ATTR_RECT, D as prefersReducedMotion, Dt as ATTR_XRAY, E as together, Et as ATTR_STATUS, F as Ghost, G as DEFAULT_THEME, H as debugging, I as GhostOptions, J as SkeletonMode, K as SkeletonAnimation, L as drawSkeleton, M as forgetShapes, Mt as RESIZE_DURATION, N as Memory, O as DEFAULT_SKELETON_BOX_OPTIONS, Ot as CASCADE_SPREAD, P as MemoryOptions, Q as applyTheme, R as motionOf, S as planReveal, St as ATTR_PANE, T as smart, Tt as ATTR_SNAPSHOT, U as setDebug, V as checkNonce, W as DEFAULT_COLORS, X as SkeletonText, Y as SkeletonSpeed, Z as SkeletonTheme, _ as WipePane, _t as ATTR_GHOST, a as exitDuration, at as TextBottom, b as byRow, bt as ATTR_LOADING, c as boxOf, ct as INLINE_SCRIPT, d as Piece, dt as SMART_SKELETON_CSS, et as themeStyleTag, f as RevealContext, ft as addStyles, g as Wipe, gt as ATTR_DEBUG, h as SKELETON_DELAY, ht as ATTR_BLOCK, i as pendingImages, it as SkeletonRect, j as skeletonBoxStyle, jt as IMAGE_TIMEOUT, k as SkeletonBoxOptions, kt as DURATIONS, l as fadeIn, lt as INLINE_STUB, m as RevealSpec, mt as ATTR_BAR, n as RevealOptions, nt as DEFAULT_TEXT, o as sweep, ot as TextTop, p as RevealMode, pt as removeStyles, q as SkeletonColors, r as imageReady, rt as SkeletonChrome, s as PaneBox, st as measureSkeleton, t as Reveal, tt as themeVariables, u as fadeOut, ut as inlineScriptTag, v as byContent, vt as ATTR_IGNORE, w as sequence, wt as ATTR_REVEAL, x as instant, xt as ATTR_OWN, y as byPosition, yt as ATTR_LAYER, z as rectsOf } from "./_chunks/index.js";
|
|
2
2
|
import { PropType, VNodeChild } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ASmartSkeleton.vue.d.ts
|
|
@@ -200,5 +200,5 @@ declare const useSmartSkeleton: () => SmartSkeletonConfig;
|
|
|
200
200
|
/** Adds the stylesheet on mount and removes it on unmount — reference counted, so siblings share one copy. */
|
|
201
201
|
declare function useStyles(): void;
|
|
202
202
|
//#endregion
|
|
203
|
-
export { _default as ASmartSkeleton, _default$1 as ASmartSkeletonBox, type ASmartSkeletonBoxProps, type ASmartSkeletonEmits, type ASmartSkeletonProps, _default$2 as ASmartSkeletonProvider, type ASmartSkeletonProviderProps, type ASmartSkeletonProviderSlots, type ASmartSkeletonSlots, _default$3 as ASmartSkeletonSuspense, type ASmartSkeletonSuspenseEmits, type ASmartSkeletonSuspenseProps, type ASmartSkeletonSuspenseSlots, ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type SmartSkeletonConfig, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together, useSmartSkeleton, useStyles };
|
|
203
|
+
export { _default as ASmartSkeleton, _default$1 as ASmartSkeletonBox, type ASmartSkeletonBoxProps, type ASmartSkeletonEmits, type ASmartSkeletonProps, _default$2 as ASmartSkeletonProvider, type ASmartSkeletonProviderProps, type ASmartSkeletonProviderSlots, type ASmartSkeletonSlots, _default$3 as ASmartSkeletonSuspense, type ASmartSkeletonSuspenseEmits, type ASmartSkeletonSuspenseProps, type ASmartSkeletonSuspenseSlots, ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonChrome, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type SmartSkeletonConfig, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together, useSmartSkeleton, useStyles };
|
|
204
204
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as skeletonCSS, A as createSkeletonBox, At as
|
|
1
|
+
import { $ as skeletonCSS, A as createSkeletonBox, At as FADE_DURATION, B as shimmer, C as quickly, Ct as ATTR_RECT, D as prefersReducedMotion, Dt as ATTR_XRAY, E as together, Et as ATTR_STATUS, F as Ghost, G as DEFAULT_THEME, H as debugging, I as GhostOptions, J as SkeletonMode, K as SkeletonAnimation, L as drawSkeleton, M as forgetShapes, Mt as RESIZE_DURATION, N as Memory, O as DEFAULT_SKELETON_BOX_OPTIONS, Ot as CASCADE_SPREAD, P as MemoryOptions, Q as applyTheme, R as motionOf, S as planReveal, St as ATTR_PANE, T as smart, Tt as ATTR_SNAPSHOT, U as setDebug, V as checkNonce, W as DEFAULT_COLORS, X as SkeletonText, Y as SkeletonSpeed, Z as SkeletonTheme, _ as WipePane, _t as ATTR_GHOST, a as exitDuration, at as TextBottom, b as byRow, bt as ATTR_LOADING, c as boxOf, ct as INLINE_SCRIPT, d as Piece, dt as SMART_SKELETON_CSS, et as themeStyleTag, f as RevealContext, ft as addStyles, g as Wipe, gt as ATTR_DEBUG, h as SKELETON_DELAY, ht as ATTR_BLOCK, i as pendingImages, it as SkeletonRect, j as skeletonBoxStyle, jt as IMAGE_TIMEOUT, k as SkeletonBoxOptions, kt as DURATIONS, l as fadeIn, lt as INLINE_STUB, m as RevealSpec, mt as ATTR_BAR, n as RevealOptions, nt as DEFAULT_TEXT, o as sweep, ot as TextTop, p as RevealMode, pt as removeStyles, q as SkeletonColors, r as imageReady, rt as SkeletonChrome, s as PaneBox, st as measureSkeleton, t as Reveal, tt as themeVariables, u as fadeOut, ut as inlineScriptTag, v as byContent, vt as ATTR_IGNORE, w as sequence, wt as ATTR_REVEAL, x as instant, xt as ATTR_OWN, y as byPosition, yt as ATTR_LAYER, z as rectsOf } from "./_chunks/index.js";
|
|
2
2
|
import { PropType, VNodeChild } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/ASmartSkeleton.vue.d.ts
|
|
@@ -200,5 +200,5 @@ declare const useSmartSkeleton: () => SmartSkeletonConfig;
|
|
|
200
200
|
/** Adds the stylesheet on mount and removes it on unmount — reference counted, so siblings share one copy. */
|
|
201
201
|
declare function useStyles(): void;
|
|
202
202
|
//#endregion
|
|
203
|
-
export { _default as ASmartSkeleton, _default$1 as ASmartSkeletonBox, type ASmartSkeletonBoxProps, type ASmartSkeletonEmits, type ASmartSkeletonProps, _default$2 as ASmartSkeletonProvider, type ASmartSkeletonProviderProps, type ASmartSkeletonProviderSlots, type ASmartSkeletonSlots, _default$3 as ASmartSkeletonSuspense, type ASmartSkeletonSuspenseEmits, type ASmartSkeletonSuspenseProps, type ASmartSkeletonSuspenseSlots, ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type SmartSkeletonConfig, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together, useSmartSkeleton, useStyles };
|
|
203
|
+
export { _default as ASmartSkeleton, _default$1 as ASmartSkeletonBox, type ASmartSkeletonBoxProps, type ASmartSkeletonEmits, type ASmartSkeletonProps, _default$2 as ASmartSkeletonProvider, type ASmartSkeletonProviderProps, type ASmartSkeletonProviderSlots, type ASmartSkeletonSlots, _default$3 as ASmartSkeletonSuspense, type ASmartSkeletonSuspenseEmits, type ASmartSkeletonSuspenseProps, type ASmartSkeletonSuspenseSlots, ATTR_BAR, ATTR_BLOCK, ATTR_DEBUG, ATTR_GHOST, ATTR_IGNORE, ATTR_LAYER, ATTR_LOADING, ATTR_OWN, ATTR_PANE, ATTR_RECT, ATTR_REVEAL, ATTR_SNAPSHOT, ATTR_STATUS, ATTR_XRAY, CASCADE_SPREAD, DEFAULT_COLORS, DEFAULT_SKELETON_BOX_OPTIONS, DEFAULT_TEXT, DEFAULT_THEME, DURATIONS, FADE_DURATION, Ghost, type GhostOptions, IMAGE_TIMEOUT, INLINE_SCRIPT, INLINE_STUB, Memory, type MemoryOptions, type PaneBox, type Piece, RESIZE_DURATION, Reveal, type RevealContext, type RevealMode, type RevealOptions, type RevealSpec, SKELETON_DELAY, SMART_SKELETON_CSS, type SkeletonAnimation, type SkeletonBoxOptions, type SkeletonChrome, type SkeletonColors, type SkeletonMode, type SkeletonRect, type SkeletonSpeed, type SkeletonText, type SkeletonTheme, type SmartSkeletonConfig, type TextBottom, type TextTop, type Wipe, type WipePane, addStyles, applyTheme, boxOf, byContent, byPosition, byRow, checkNonce, createSkeletonBox, debugging, drawSkeleton, exitDuration, fadeIn, fadeOut, forgetShapes, imageReady, inlineScriptTag, instant, measureSkeleton, motionOf, pendingImages, planReveal, prefersReducedMotion, quickly, rectsOf, removeStyles, sequence, setDebug, shimmer, skeletonBoxStyle, skeletonCSS, smart, sweep, themeStyleTag, themeVariables, together, useSmartSkeleton, useStyles };
|
|
204
204
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/styles.css
CHANGED
|
@@ -1,2 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
[ask-reveal] {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
a-smart-skeleton-reveal,
|
|
6
|
+
ask-reveal {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
a-smart-skeleton-reveal[loading]:not(:defined),
|
|
11
|
+
ask-reveal[loading]:not(:defined) {
|
|
12
|
+
visibility: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[ask-pane] {
|
|
16
|
+
display: block;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
[ask-loading] {
|
|
20
|
+
position: relative;
|
|
21
|
+
-webkit-user-select: none;
|
|
22
|
+
user-select: none;
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[ask-inactive] {
|
|
27
|
+
display: none !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
[ask-layer] {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset: 0;
|
|
33
|
+
overflow: visible;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[ask-bar] {
|
|
37
|
+
display: block;
|
|
38
|
+
background-color: var(--ask-base, rgb(128 128 128 / 0.2));
|
|
39
|
+
background-repeat: no-repeat;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* Bones drawn by `drawSkeleton` live in the light DOM (no shadow root), so a
|
|
44
|
+
* consumer can target them with their own stylesheet. Positioning stays inline
|
|
45
|
+
* (per-bone), but the fill colour reads from a CSS custom property so the
|
|
46
|
+
* consumer's theme flows through — set `--ask-base` on any ancestor to
|
|
47
|
+
* recolour every bone inside it, or use the type modifier to style text / media
|
|
48
|
+
* / box bones separately.
|
|
49
|
+
*
|
|
50
|
+
* Chrome bones are excluded: they reproduce the consumer's own container paint
|
|
51
|
+
* (background, border, shadow) that `captureChrome` snapshotted, so they must
|
|
52
|
+
* NOT get a generic fill underneath. Without the `:not()`, a bordered-only
|
|
53
|
+
* container (e.g. a footer with `border-t`) would show as a solid filled
|
|
54
|
+
* rectangle instead of just its captured divider.
|
|
55
|
+
*/
|
|
56
|
+
[ask-rect]:not([ask-rect="chrome"]) {
|
|
57
|
+
background-color: var(--ask-base, var(--ask-block, var(--ak-skeleton-block, rgb(128 128 128 / 0.2))));
|
|
58
|
+
background-repeat: no-repeat;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Containers keep their surface; what they hold is drawn by bones, measured before the first paint */
|
|
62
|
+
@scope ([ask-loading]) to ([ask-own], [ask-layer]) {
|
|
63
|
+
:scope,
|
|
64
|
+
:scope * {
|
|
65
|
+
color: transparent !important;
|
|
66
|
+
-webkit-text-fill-color: transparent !important;
|
|
67
|
+
text-shadow: none !important;
|
|
68
|
+
text-decoration-color: transparent !important;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:scope ::placeholder {
|
|
72
|
+
color: transparent !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* A line to measure in empty text; content only, never a size, or a dot-sized span would grow round it */
|
|
76
|
+
:scope :is(a, b, code, dd, dt, em, h1, h2, h3, h4, h5, h6, i, label, li, p, small, span, strong, td, th, time):empty:not(svg *)::before {
|
|
77
|
+
content: "000000";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Leaves are drawn by bones, so their own paint never shows; visibility, as measuring reads it */
|
|
81
|
+
:scope :is(:not(:has(*)), audio, canvas, embed, iframe, img, input, object, picture, select, svg, textarea, video, [ask-covered], [ask-block]):not(svg *) {
|
|
82
|
+
visibility: hidden !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* No script to measure: a bar struck through each line of text instead */
|
|
86
|
+
@media (scripting: none) {
|
|
87
|
+
:scope :not(:has(*)):not(svg *) {
|
|
88
|
+
visibility: visible !important;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:scope,
|
|
92
|
+
:scope * {
|
|
93
|
+
text-decoration: line-through var(--ask-base, rgb(128 128 128 / 0.2)) !important;
|
|
94
|
+
text-decoration-thickness: 0.72em !important;
|
|
95
|
+
text-decoration-skip-ink: none !important;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:scope :is(audio, canvas, embed, iframe, img, input, object, picture, select, svg, textarea, video, [ask-block]):not(svg *) {
|
|
99
|
+
visibility: visible !important;
|
|
100
|
+
background: var(--ask-base, rgb(128 128 128 / 0.2)) !important;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:scope svg * {
|
|
104
|
+
fill: transparent !important;
|
|
105
|
+
stroke: transparent !important;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
:scope :is(img, video) {
|
|
109
|
+
object-position: -100vw 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Read by screen readers in the skeleton's place, never seen */
|
|
115
|
+
[ask-status] {
|
|
116
|
+
position: absolute;
|
|
117
|
+
width: 1px;
|
|
118
|
+
height: 1px;
|
|
119
|
+
margin: -1px;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
clip-path: inset(50%);
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Debug x-ray: the ghost shown through its bones, to see what was measured */
|
|
126
|
+
[ask-xray] [ask-loading] [ask-ghost],
|
|
127
|
+
[ask-xray] [ask-loading] [ask-ghost] *:not(svg *) {
|
|
128
|
+
visibility: visible !important;
|
|
129
|
+
color: rgb(255 0 80 / 0.7) !important;
|
|
130
|
+
-webkit-text-fill-color: rgb(255 0 80 / 0.7) !important;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Lets addStyles see a stylesheet already on the page, from styles.css or a server render */
|
|
134
|
+
:root {
|
|
135
|
+
--ask: 1;
|
|
136
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alikhalilll/a-smart-skeleton",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Smart, measured skeleton loaders for Vue 3 / Nuxt 3+. Lays the real content out unseen, draws a skeleton from its geometry, then reveals it with smart, sequence, sweep or together animations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "alikhalilll",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
},
|
|
136
136
|
"scripts": {
|
|
137
137
|
"clean": "rimraf dist web-types.json",
|
|
138
|
-
"build": "node scripts/build-inline.mjs && tsx ../../../scripts/build/run-component-build.ts",
|
|
138
|
+
"build": "node scripts/build-inline.mjs && tsx ../../../scripts/build/run-component-build.ts && node scripts/build-css.mjs",
|
|
139
139
|
"dev": "node scripts/build-inline.mjs && tsdown --watch",
|
|
140
140
|
"test": "vitest run",
|
|
141
141
|
"test:watch": "vitest",
|
package/src/core/fade.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
ATTR_OWN,
|
|
7
7
|
ATTR_PANE,
|
|
8
8
|
ATTR_SNAPSHOT,
|
|
9
|
-
BASE,
|
|
10
9
|
FADE_DURATION,
|
|
11
10
|
RESIZE_DURATION,
|
|
12
11
|
} from './constants';
|
|
@@ -88,7 +87,9 @@ function holdImages(element: HTMLElement, root: HTMLElement) {
|
|
|
88
87
|
const bone = bones.find((b) => sameBox(b.getBoundingClientRect(), rect));
|
|
89
88
|
const box = bone?.getBoundingClientRect() ?? rect;
|
|
90
89
|
const stand = document.createElement('div');
|
|
91
|
-
|
|
90
|
+
// Same "media"-type bone the main pass produces — fill colour comes from the
|
|
91
|
+
// stylesheet (`[ask-rect]` → `var(--ask-base)`) so a consumer theme reaches it.
|
|
92
|
+
stand.setAttribute(ATTR_RECT, 'media');
|
|
92
93
|
Object.assign(stand.style, {
|
|
93
94
|
position: 'absolute',
|
|
94
95
|
left: `${box.left - origin.left - root.clientLeft}px`,
|
|
@@ -96,7 +97,6 @@ function holdImages(element: HTMLElement, root: HTMLElement) {
|
|
|
96
97
|
width: `${box.width}px`,
|
|
97
98
|
height: `${box.height}px`,
|
|
98
99
|
borderRadius: bone?.style.borderRadius || getComputedStyle(image).borderRadius,
|
|
99
|
-
backgroundColor: BASE,
|
|
100
100
|
backgroundRepeat: 'no-repeat',
|
|
101
101
|
pointerEvents: 'none',
|
|
102
102
|
});
|
package/src/core/index.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type {
|
|
|
40
40
|
export { debugging, setDebug } from './debug';
|
|
41
41
|
export { checkNonce } from './dev';
|
|
42
42
|
export { DEFAULT_TEXT, measureSkeleton } from './measure';
|
|
43
|
-
export type { SkeletonRect, TextBottom, TextTop } from './measure';
|
|
43
|
+
export type { SkeletonChrome, SkeletonRect, TextBottom, TextTop } from './measure';
|
|
44
44
|
export { rectsOf, drawSkeleton, motionOf, shimmer } from './shimmer';
|
|
45
45
|
export { Ghost } from './ghost';
|
|
46
46
|
export type { GhostOptions } from './ghost';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by scripts/build-inline.mjs from boot.ts — don't edit
|
|
2
|
-
export const INLINE_SCRIPT = "\"use strict\";(()=>{var B=\"ask-ghost\";var D=\"ask-layer\",L=\"ask-rect\";var R=\"ask-covered\",$=\"ask-own\",v=\"ask-ignore\",H=\"ask-block\",I=Symbol.for(\"a-smart-skeleton.ghost\"),G=Symbol.for(\"a-smart-skeleton.uncover\"),P=\"a-smart-skeleton.boot\";var W=\"var(--ask-base, rgb(128 128 128 / 0.2))\",z=\"var(--ask-highlight, rgb(255 255 255 / 0.12))\";var F={shimmer:{slow:4e3,fast:2e3},pulse:{slow:2400,fast:1200}},X=[\"a\",\"b\",\"code\",\"dd\",\"dt\",\"em\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"i\",\"label\",\"li\",\"p\",\"small\",\"span\",\"strong\",\"td\",\"th\",\"time\"],U=[\"audio\",\"canvas\",\"embed\",\"iframe\",\"img\",\"input\",\"object\",\"picture\",\"select\",\"svg\",\"textarea\",\"video\"];var gt,V=()=>gt??(gt=/jsdom/.test(navigator.userAgent)?null:document.createElement(\"canvas\").getContext(\"2d\"));var J=(t,n)=>t?{left:Math.max(t.left,n.left),right:Math.min(t.right,n.right),top:Math.max(t.top,n.top),bottom:Math.min(t.bottom,n.bottom)}:n,A=t=>[[t.left,t.top],[t.right,t.top],[t.right,t.bottom],[t.left,t.bottom]],k=(t,n)=>Math.abs(t[0]-n[0])<1&&Math.abs(t[1]-n[1])<1;function Q(t,n){let e=Math.min(n.right-n.left,n.bottom-n.top),o=r=>r.endsWith(\"%\")?parseFloat(r)/100*e:parseFloat(r)||0;return[o(t.borderTopLeftRadius),o(t.borderTopRightRadius),o(t.borderBottomRightRadius),o(t.borderBottomLeftRadius)]}function bt(t,n,e){let o=J(t,n),r=Q(e,n),c=t?A(t):[],a=A(n),m=A(o).map((f,T)=>k(f,a[T])?r[T]:t&&k(f,c[T])?t.corners[T]:0),{left:s,right:i,top:l,bottom:h}=o;return{left:s,right:i,top:l,bottom:h,corners:m}}function Tt(t,n,e,o){if(!t)return e;let r=A(t),c=A(n).map((m,s)=>t.corners[s]>0&&k(m,r[s]));if(!c.some(Boolean))return e;let a=Q(o,n);return c.map((m,s)=>m?Math.max(a[s],t.corners[s]):a[s]).map(m=>`${m}px`).join(\" \")}var j=(t,n)=>{let e=J(n,t);return e.right-e.left>=2&&e.bottom-e.top>=2?e:null},q={top:\"ascender\",bottom:\"descender\"},C=new Map,tt=t=>[...t.getClientRects?.()??[]];function St(t){let n=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;if(C.has(n))return C.get(n);let e=V(),o=null;if(e){e.font=n;let r=e.measureText(\"H\"),c=a=>e.measureText(a).actualBoundingBoxAscent;o={ascent:r.fontBoundingBoxAscent,descent:r.fontBoundingBoxDescent,ascender:c(\"bdfhkl\"),capHeight:r.actualBoundingBoxAscent,xHeight:c(\"xz\"),descender:e.measureText(\"gjpqy\").actualBoundingBoxDescent}}return C.set(n,o),o}var Y={ascender:\"ascender\",\"cap-height\":\"capHeight\",\"x-height\":\"xHeight\"},K=(t,n,e,o)=>{let r=t.getPropertyValue(n).trim();return e.includes(r)?r:o};function xt(t,n,e){let o=St(n);if(!o){let s=Math.min(e*.72,t.bottom-t.top),i=(t.top+t.bottom)/2;return{barTop:i-s/2,barBottom:i+s/2}}let r=K(n,\"--ask-text-top\",Object.keys(Y),q.top),c=K(n,\"--ask-text-bottom\",[\"baseline\",\"descender\"],q.bottom),a=o.ascent+o.descent,m=t.top+(t.bottom-t.top-a)/2+o.ascent;return{barTop:m-o[Y[r]],barBottom:m+(c===\"descender\"?o.descender:0)}}var Et=new Set(U),Rt=new Set(X),et=.4,At=/[,/]\\s*0\\)$/,y=(t,n)=>t!==\"\"&&t!==n,yt=[\"Top\",\"Right\",\"Bottom\",\"Left\"],Mt=t=>yt.every(n=>y(t[`border${n}Style`],\"none\")&&y(t[`border${n}Width`],\"0px\")),Ct=t=>{let[n=0,e=0,o=0,r=0]=(t.replace(/rgba?\\([^)]*\\)|#\\w+/g,\"\").match(/-?[\\d.]+px/g)??[]).map(parseFloat);return t.includes(\"inset\")&&!o&&!r&&n===0!=(e===0)&&Math.abs(n+e)<=2},kt=t=>y(t,\"none\")&&!t.split(/,(?![^(]*\\))/).every(Ct),Ot=t=>y(t.backgroundColor,\"transparent\")&&!At.test(t.backgroundColor)||y(t.backgroundImage,\"none\")||kt(t.boxShadow)||Mt(t),ot=t=>Et.has(t.localName),nt=t=>Rt.has(t.localName)&&!t.firstElementChild&&!t.textContent?.trim(),wt=t=>{let n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT),e=document.createRange(),o=[],r=0;for(;n.nextNode();){let i=n.currentNode;if(i.nodeType===Node.TEXT_NODE){let l=i.parentElement;if(!i.textContent?.trim()||!l)continue;r++;let h=l.getBoundingClientRect();if(h.width<=1||h.height<=1)continue;e.selectNodeContents(i),o.push(tt(e).filter(f=>f.width||f.height))}else nt(i)&&(r++,o.push([...i.getClientRects()]))}if(!o.some(i=>i.length))return r;let c=(parseFloat(getComputedStyle(t).fontSize)||16)*et,a=(i,l)=>Math.min(i.bottom,l.bottom)-Math.max(i.top,l.top)>=Math.min(i.height,l.height)/2&&Math.max(i.left,l.left)-Math.min(i.right,l.right)<=c,m=o.map((i,l)=>l),s=i=>m[i]===i?i:m[i]=s(m[i]);for(let i=0;i<o.length;i++)for(let l=i+1;l<o.length;l++)o[i].some(h=>o[l].some(f=>a(h,f)))&&(m[s(l)]=s(i));return new Set(o.map((i,l)=>s(l))).size},Nt=(t,n)=>t.hasAttribute(H)||ot(t)||Ot(n)&&wt(t)<=1;function _t(t,n){if(parseFloat(n.borderRadius)||!t.parentElement)return n.borderRadius||\"0px\";let e=t.parentElement,o=getComputedStyle(e),r=t.getBoundingClientRect(),c=e.getBoundingClientRect();return Math.abs(r.width-c.width)<1&&Math.abs(r.height-c.height)<1&&o.overflow!==\"visible\"?o.borderRadius:n.borderRadius||\"0px\"}function Z(t){t.sort((e,o)=>e.left-o.left);let n=[];for(let e of t){let o=n.find(r=>{let c=Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top),a=Math.min(r.bottom-r.top,e.bottom-e.top),m=e.left-r.right;return c>=a/2&&m<=Math.max(r.fontSize,e.fontSize)*et});o?(o.left=Math.min(o.left,e.left),o.right=Math.max(o.right,e.right),o.top=Math.min(o.top,e.top),o.bottom=Math.max(o.bottom,e.bottom),o.fontSize=Math.max(o.fontSize,e.fontSize),o.barTop=Math.min(o.barTop,e.barTop),o.barBottom=Math.max(o.barBottom,e.barBottom)):n.push({...e})}return n.map(e=>{let o=e.barBottom-e.barTop;return{x:e.left,y:e.barTop,width:e.right-e.left,height:o,radius:e.radius||`${Math.round(o/3)}px`}})}function rt(t,n,{mark:e=!0,onCovered:o}={}){let r=n.getBoundingClientRect(),c=n.offsetWidth?r.width/n.offsetWidth:1,a=n.offsetHeight?r.height/n.offsetHeight:1,m=d=>({left:(d.left-r.left)/c,right:(d.right-r.left)/c,top:(d.top-r.top)/a,bottom:(d.bottom-r.top)/a}),s=[],i=[],l=new Set,h=document.createRange(),f=(d,g,b)=>{let u=j(d,b);if(!u)return;let p=parseFloat(g.fontSize)||16,M=m(u);i.push({...M,fontSize:p,...xt(M,g,p),radius:g.getPropertyValue(\"--ask-radius\").trim()})},T=(d,g)=>{let b=d.data.search(/\\S/);if(b<0||!d.parentElement)return;h.setStart(d,b),h.setEnd(d,d.data.trimEnd().length);let u=getComputedStyle(d.parentElement);for(let p of tt(h))f(p,u,g)},_=(d,g)=>{for(let b of d.childNodes){if(b.nodeType===Node.TEXT_NODE){T(b,g);continue}if(b.nodeType!==Node.ELEMENT_NODE)continue;let u=b;if(u.hasAttribute(v)||u.hasAttribute($))continue;let p=getComputedStyle(u);if(p.display===\"none\")continue;if(Nt(u,p)){let E=j(u.getBoundingClientRect(),g);if(E){let S=m(E);s.push({x:S.left,y:S.top,width:S.right-S.left,height:S.bottom-S.top,radius:Tt(g,E,_t(u,p),p)})}ot(u)||l.add(u);continue}if(nt(u)){for(let E of u.getClientRects())f(E,p,g);continue}let M=p.overflowX!==\"visible\"||p.overflowY!==\"visible\";_(u,M?bt(g,u.getBoundingClientRect(),p):g)}};if(_(t,null),o?.(l),!e)return[...s,...Z(i)];for(let d of t.querySelectorAll(`[${R}]`))l.has(d)||d.removeAttribute(R);for(let d of l)d.hasAttribute(R)||d.setAttribute(R,\"\");return[...s,...Z(i)]}var Bt=t=>typeof matchMedia<\"u\"&&matchMedia(t).matches,Dt=()=>typeof Element<\"u\"&&typeof Element.prototype.animate==\"function\",st=()=>!Dt()||Bt(\"(prefers-reduced-motion: reduce)\");var it=t=>t.getAnimations?.()??[];var Lt=.7,$t=1280,at=320,vt=2.5,Ht=.45,It=[\"shimmer\",\"group-shimmer\",\"pulse\",\"none\"];function mt(t){let n=getComputedStyle(t),e=(c,a,m)=>{let s=n.getPropertyValue(c).trim();return a.includes(s)?s:m},o=e(\"--ask-animation\",It,\"shimmer\"),r=e(\"--ask-speed\",[\"slow\",\"fast\"],\"slow\");return{animation:o,duration:F[o===\"pulse\"?\"pulse\":\"shimmer\"][r]}}var w=20,Gt=Math.sin(w*Math.PI/180),lt=Math.cos(w*Math.PI/180),Pt=Gt/lt;var Wt=`${90+w}deg`,O=.85,x=12,ct=t=>(1-Math.cos(Math.PI*t))/2;function zt(t){let n=t*vt,e=(r,c)=>`color-mix(in srgb, ${z} ${(c*100).toFixed(1)}%, transparent) ${(r*t).toFixed(2)}px`,o=[];for(let r=0;r<=x;r++)o.push(e(r/x*O,ct(r/x)));for(let r=1;r<=x;r++)o.push(e(O+r/x*(1-O),ct(1-r/x)));return{width:n/lt,image:`repeating-linear-gradient(${Wt}, ${o.join(\", \")}, transparent ${n.toFixed(2)}px)`}}function Ft(t,n,e=mt(t)){for(let f of it(t))f.cancel();if(t.style.backgroundImage=\"\",t.style.backgroundRepeat=\"\",st()||typeof t.animate!=\"function\"||e.animation===\"none\")return;let o={duration:e.duration,iterations:1/0};if(e.animation===\"pulse\"){t.animate([{opacity:1,easing:\"ease-in-out\"},{opacity:Ht,easing:\"ease-in-out\"},{opacity:1}],o).startTime=0;return}let r=t.getBoundingClientRect(),c=r.left+scrollX,a=e.animation===\"group-shimmer\"?n??{left:c,top:r.top,width:r.width,height:r.height}:{left:0,top:0,width:document.documentElement.clientWidth||innerWidth,height:innerHeight},m=Math.min(Math.max(a.width*.4,80),at),{width:s,image:i}=zt(m),l=c-a.left+(r.top-a.top)*Pt,h=e.duration*Lt/($t+at);t.style.backgroundImage=i,t.style.backgroundSize=`${s}px 100%`,t.style.backgroundRepeat=\"repeat-x\",t.animate([{backgroundPosition:`${-l}px 0`},{backgroundPosition:`${s-l}px 0`}],{duration:s*h,iterations:1/0}).startTime=0}var Xt=t=>t.shadowRoot??t.attachShadow({mode:\"open\"});function dt(t,n){let e=Xt(t),o=t.getBoundingClientRect(),r={left:o.left+scrollX,top:o.top,width:o.width,height:o.height},c=mt(t);for(n.forEach((a,m)=>{let s=e.children[m];s||(s=document.createElement(\"div\"),s.setAttribute(L,\"\"),s.style.cssText=`position:absolute;display:block;pointer-events:none;background-color:${W};background-repeat:no-repeat`,e.append(s)),Object.assign(s.style,{left:`${a.x}px`,top:`${a.y}px`,width:`${a.width}px`,height:`${a.height}px`,borderRadius:a.radius});let i=`${Math.round(r.left+a.x)}|${Math.round(a.y)}|${Math.round(a.height)}|${Math.round(r.left)}|${Math.round(r.width)}|${Math.round(r.height)}|${document.documentElement.clientWidth}|${c.animation}|${c.duration}`;s.dataset.motion!==i&&(s.dataset.motion=i,Ft(s,r,c))});e.children.length>n.length;)e.lastElementChild.remove()}var pt=t=>t.parentElement?`${pt(t.parentElement)} > :nth-child(${[...t.parentElement.children].indexOf(t)+1})`:\":root\";function N(t){let n=t?.previousElementSibling,e=n?.querySelector(`:scope > [${B}]`),o=n?.querySelector(`:scope > [${D}]`);if(!n||!e||!o)return;let r=typeof CSSStyleSheet==\"function\"&&\"replaceSync\"in CSSStyleSheet.prototype?new CSSStyleSheet:null;r&&(document.adoptedStyleSheets=[...document.adoptedStyleSheets,r],n[G]=()=>{document.adoptedStyleSheets=document.adoptedStyleSheets.filter(s=>s!==r)});let c=s=>r?.replaceSync(s.size?`${[...s].map(pt).join(\", \")} { visibility: hidden !important; }`:\"\"),a=()=>{if(!o.isConnected||n[I])return m.disconnect();e.getClientRects().length&&dt(o,rt(e,o,{mark:!1,onCovered:c}))},m=new ResizeObserver(a);m.observe(n),document.fonts?.ready.then(a)}var ht=self,ft=Symbol.for(P),ut=ht[ft];ht[ft]=N;Array.isArray(ut)&&ut.forEach(N);N(document.currentScript);})();";
|
|
2
|
+
export const INLINE_SCRIPT = "\"use strict\";(()=>{var H=\"ask-ghost\";var G=\"ask-layer\",M=\"ask-rect\";var A=\"ask-covered\",P=\"ask-own\",W=\"ask-ignore\",F=\"ask-block\",z=Symbol.for(\"a-smart-skeleton.ghost\"),U=Symbol.for(\"a-smart-skeleton.uncover\"),X=\"a-smart-skeleton.boot\";var j=\"var(--ask-highlight, rgb(255 255 255 / 0.12))\";var V={shimmer:{slow:4e3,fast:2e3},pulse:{slow:2400,fast:1200}},q=[\"a\",\"b\",\"code\",\"dd\",\"dt\",\"em\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"i\",\"label\",\"li\",\"p\",\"small\",\"span\",\"strong\",\"td\",\"th\",\"time\"],Y=[\"audio\",\"canvas\",\"embed\",\"iframe\",\"img\",\"input\",\"object\",\"picture\",\"select\",\"svg\",\"textarea\",\"video\"];var Et,K=()=>Et??(Et=/jsdom/.test(navigator.userAgent)?null:document.createElement(\"canvas\").getContext(\"2d\"));var nt=(t,e)=>t?{left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}:e,k=t=>[[t.left,t.top],[t.right,t.top],[t.right,t.bottom],[t.left,t.bottom]],$=(t,e)=>Math.abs(t[0]-e[0])<1&&Math.abs(t[1]-e[1])<1;function rt(t,e){let r=Math.min(e.right-e.left,e.bottom-e.top),o=n=>n.endsWith(\"%\")?parseFloat(n)/100*r:parseFloat(n)||0;return[o(t.borderTopLeftRadius),o(t.borderTopRightRadius),o(t.borderBottomRightRadius),o(t.borderBottomLeftRadius)]}function At(t,e,r){let o=nt(t,e),n=rt(r,e),c=t?k(t):[],i=k(e),l=k(o).map((b,R)=>$(b,i[R])?n[R]:t&&$(b,c[R])?t.corners[R]:0),{left:s,right:a,top:d,bottom:h}=o;return{left:s,right:a,top:d,bottom:h,corners:l}}function Z(t,e,r,o){if(!t)return r;let n=k(t),c=k(e).map((l,s)=>t.corners[s]>0&&$(l,n[s]));if(!c.some(Boolean))return r;let i=rt(o,e);return c.map((l,s)=>l?Math.max(i[s],t.corners[s]):i[s]).map(l=>`${l}px`).join(\" \")}var O=(t,e)=>{let r=nt(e,t);return r.right-r.left>=2&&r.bottom-r.top>=2?r:null},J={top:\"ascender\",bottom:\"descender\"},w=new Map,st=t=>[...t.getClientRects?.()??[]];function kt(t){let e=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`;if(w.has(e))return w.get(e);let r=K(),o=null;if(r){r.font=e;let n=r.measureText(\"H\"),c=i=>r.measureText(i).actualBoundingBoxAscent;o={ascent:n.fontBoundingBoxAscent,descent:n.fontBoundingBoxDescent,ascender:c(\"bdfhkl\"),capHeight:n.actualBoundingBoxAscent,xHeight:c(\"xz\"),descender:r.measureText(\"gjpqy\").actualBoundingBoxDescent}}return w.set(e,o),o}var Q={ascender:\"ascender\",\"cap-height\":\"capHeight\",\"x-height\":\"xHeight\"},tt=(t,e,r,o)=>{let n=t.getPropertyValue(e).trim();return r.includes(n)?n:o};function Ct(t,e,r){let o=kt(e);if(!o){let s=Math.min(r*.72,t.bottom-t.top),a=(t.top+t.bottom)/2;return{barTop:a-s/2,barBottom:a+s/2}}let n=tt(e,\"--ask-text-top\",Object.keys(Q),J.top),c=tt(e,\"--ask-text-bottom\",[\"baseline\",\"descender\"],J.bottom),i=o.ascent+o.descent,l=t.top+(t.bottom-t.top-i)/2+o.ascent;return{barTop:l-o[Q[n]],barBottom:l+(c===\"descender\"?o.descender:0)}}var Mt=new Set(Y),Ot=new Set(q),it=.4,at=/[,/]\\s*0\\)$/,g=(t,e)=>t!==\"\"&&t!==e,N=[\"Top\",\"Right\",\"Bottom\",\"Left\"],wt=t=>N.every(e=>g(t[`border${e}Style`],\"none\")&&g(t[`border${e}Width`],\"0px\")),$t=t=>N.some(e=>g(t[`border${e}Style`],\"none\")&&g(t[`border${e}Width`],\"0px\")),Bt=t=>{let[e=0,r=0,o=0,n=0]=(t.replace(/rgba?\\([^)]*\\)|#\\w+/g,\"\").match(/-?[\\d.]+px/g)??[]).map(parseFloat);return t.includes(\"inset\")&&!o&&!n&&e===0!=(r===0)&&Math.abs(e+r)<=2},ct=t=>g(t,\"none\")&&!t.split(/,(?![^(]*\\))/).every(Bt);function Nt(t){let e=[],r=0,o=0;for(let n=0;n<t.length;n++){let c=t[n];c===\"(\"?r++:c===\")\"?r--:c===\",\"&&r===0&&(e.push(t.slice(o,n)),o=n+1)}return e.push(t.slice(o)),e.map(n=>n.trim()).filter(n=>n&&!n.startsWith(\"url(\")).join(\", \")}var dt=t=>g(t.backgroundColor,\"transparent\")&&!at.test(t.backgroundColor)||g(t.backgroundImage,\"none\")||ct(t.boxShadow)||wt(t);function _t(t){let e={},r=t.backgroundColor;g(r,\"transparent\")&&!at.test(r)&&(e.background=r);let o=t.backgroundImage;if(g(o,\"none\")){let n=Nt(o);n&&(e.background=e.background?`${n}, ${e.background}`:n)}for(let n of N){let c=t[`border${n}Width`],i=t[`border${n}Style`],l=t[`border${n}Color`];if(g(i,\"none\")&&g(c,\"0px\")&&parseFloat(c)>0){let s=`border${n}`;e[s]=`${c} ${i} ${l}`}}return ct(t.boxShadow)&&(e.boxShadow=t.boxShadow),Object.keys(e).length?e:void 0}var B=t=>Mt.has(t.localName),lt=t=>Ot.has(t.localName)&&!t.firstElementChild&&!t.textContent?.trim(),Dt=t=>{let e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT),r=document.createRange(),o=[],n=0;for(;e.nextNode();){let a=e.currentNode;if(a.nodeType===Node.TEXT_NODE){let d=a.parentElement;if(!a.textContent?.trim()||!d)continue;n++;let h=d.getBoundingClientRect();if(h.width<=1||h.height<=1)continue;r.selectNodeContents(a),o.push(st(r).filter(b=>b.width||b.height))}else lt(a)&&(n++,o.push([...a.getClientRects()]))}if(!o.some(a=>a.length))return n;let c=(parseFloat(getComputedStyle(t).fontSize)||16)*it,i=(a,d)=>Math.min(a.bottom,d.bottom)-Math.max(a.top,d.top)>=Math.min(a.height,d.height)/2&&Math.max(a.left,d.left)-Math.min(a.right,d.right)<=c,l=o.map((a,d)=>d),s=a=>l[a]===a?a:l[a]=s(l[a]);for(let a=0;a<o.length;a++)for(let d=a+1;d<o.length;d++)o[a].some(h=>o[d].some(b=>i(h,b)))&&(l[s(d)]=s(a));return new Set(o.map((a,d)=>s(d))).size},Lt=(t,e)=>t.hasAttribute(F)||B(t)||dt(e)&&Dt(t)<=1;function et(t,e){if(parseFloat(e.borderRadius)||!t.parentElement)return e.borderRadius||\"0px\";let r=t.parentElement,o=getComputedStyle(r),n=t.getBoundingClientRect(),c=r.getBoundingClientRect();return Math.abs(n.width-c.width)<1&&Math.abs(n.height-c.height)<1&&o.overflow!==\"visible\"?o.borderRadius:e.borderRadius||\"0px\"}function ot(t){t.sort((r,o)=>r.left-o.left);let e=[];for(let r of t){let o=e.find(n=>{let c=Math.min(n.bottom,r.bottom)-Math.max(n.top,r.top),i=Math.min(n.bottom-n.top,r.bottom-r.top),l=r.left-n.right;return c>=i/2&&l<=Math.max(n.fontSize,r.fontSize)*it});o?(o.left=Math.min(o.left,r.left),o.right=Math.max(o.right,r.right),o.top=Math.min(o.top,r.top),o.bottom=Math.max(o.bottom,r.bottom),o.fontSize=Math.max(o.fontSize,r.fontSize),o.barTop=Math.min(o.barTop,r.barTop),o.barBottom=Math.max(o.barBottom,r.barBottom)):e.push({...r})}return e.map(r=>{let o=r.barBottom-r.barTop;return{type:\"text\",x:r.left,y:r.barTop,width:r.right-r.left,height:o,radius:r.radius||`${Math.round(o/3)}px`}})}function mt(t,e,{mark:r=!0,onCovered:o}={}){let n=e.getBoundingClientRect(),c=e.offsetWidth?n.width/e.offsetWidth:1,i=e.offsetHeight?n.height/e.offsetHeight:1,l=m=>({left:(m.left-n.left)/c,right:(m.right-n.left)/c,top:(m.top-n.top)/i,bottom:(m.bottom-n.top)/i}),s=[],a=[],d=new Set,h=document.createRange(),b=(m,f,T)=>{let u=O(m,T);if(!u)return;let p=parseFloat(f.fontSize)||16,C=l(u);a.push({...C,fontSize:p,...Ct(C,f,p),radius:f.getPropertyValue(\"--ask-radius\").trim()})},R=(m,f)=>{let T=m.data.search(/\\S/);if(T<0||!m.parentElement)return;h.setStart(m,T),h.setEnd(m,m.data.trimEnd().length);let u=getComputedStyle(m.parentElement);for(let p of st(h))b(p,u,f)},I=(m,f)=>{for(let T of m.childNodes){if(T.nodeType===Node.TEXT_NODE){R(T,f);continue}if(T.nodeType!==Node.ELEMENT_NODE)continue;let u=T;if(u.hasAttribute(W)||u.hasAttribute(P))continue;let p=getComputedStyle(u);if(p.display===\"none\")continue;if(Lt(u,p)){let x=O(u.getBoundingClientRect(),f);if(x){let S=l(x);s.push({type:B(u)?\"media\":\"box\",x:S.left,y:S.top,width:S.right-S.left,height:S.bottom-S.top,radius:Z(f,x,et(u,p),p)})}B(u)||d.add(u);continue}if(lt(u)){for(let x of u.getClientRects())b(x,p,f);continue}if(dt(p)||$t(p)){let x=_t(p);if(x){let S=O(u.getBoundingClientRect(),f);if(S){let y=l(S);s.push({type:\"chrome\",x:y.left,y:y.top,width:y.right-y.left,height:y.bottom-y.top,radius:Z(f,S,et(u,p),p),chrome:x})}}}let C=p.overflowX!==\"visible\"||p.overflowY!==\"visible\";I(u,C?At(f,u.getBoundingClientRect(),p):f)}};if(I(t,null),o?.(d),!r)return[...s,...ot(a)];for(let m of t.querySelectorAll(`[${A}]`))d.has(m)||m.removeAttribute(A);for(let m of d)m.hasAttribute(A)||m.setAttribute(A,\"\");return[...s,...ot(a)]}var vt=t=>typeof matchMedia<\"u\"&&matchMedia(t).matches,It=()=>typeof Element<\"u\"&&typeof Element.prototype.animate==\"function\",ut=()=>!It()||vt(\"(prefers-reduced-motion: reduce)\");var _=t=>t.getAnimations?.()??[];var Ht=.7,Gt=1280,pt=320,Pt=2.5,Wt=.45,Ft=[\"shimmer\",\"group-shimmer\",\"pulse\",\"none\"];function bt(t){let e=getComputedStyle(t),r=(c,i,l)=>{let s=e.getPropertyValue(c).trim();return i.includes(s)?s:l},o=r(\"--ask-animation\",Ft,\"shimmer\"),n=r(\"--ask-speed\",[\"slow\",\"fast\"],\"slow\");return{animation:o,duration:V[o===\"pulse\"?\"pulse\":\"shimmer\"][n]}}var L=20,zt=Math.sin(L*Math.PI/180),gt=Math.cos(L*Math.PI/180),Ut=zt/gt;var Xt=`${90+L}deg`,D=.85,E=12,ht=t=>(1-Math.cos(Math.PI*t))/2;function jt(t){let e=t*Pt,r=(n,c)=>`color-mix(in srgb, ${j} ${(c*100).toFixed(1)}%, transparent) ${(n*t).toFixed(2)}px`,o=[];for(let n=0;n<=E;n++)o.push(r(n/E*D,ht(n/E)));for(let n=1;n<=E;n++)o.push(r(D+n/E*(1-D),ht(1-n/E)));return{width:e/gt,image:`repeating-linear-gradient(${Xt}, ${o.join(\", \")}, transparent ${e.toFixed(2)}px)`}}function Vt(t,e,r=bt(t)){for(let b of _(t))b.cancel();if(t.style.backgroundImage=\"\",t.style.backgroundRepeat=\"\",ut()||typeof t.animate!=\"function\"||r.animation===\"none\")return;let o={duration:r.duration,iterations:1/0};if(r.animation===\"pulse\"){t.animate([{opacity:1,easing:\"ease-in-out\"},{opacity:Wt,easing:\"ease-in-out\"},{opacity:1}],o).startTime=0;return}let n=t.getBoundingClientRect(),c=n.left+scrollX,i=r.animation===\"group-shimmer\"?e??{left:c,top:n.top,width:n.width,height:n.height}:{left:0,top:0,width:document.documentElement.clientWidth||innerWidth,height:innerHeight},l=Math.min(Math.max(i.width*.4,80),pt),{width:s,image:a}=jt(l),d=c-i.left+(n.top-i.top)*Ut,h=r.duration*Ht/(Gt+pt);t.style.backgroundImage=a,t.style.backgroundSize=`${s}px 100%`,t.style.backgroundRepeat=\"repeat-x\",t.animate([{backgroundPosition:`${-d}px 0`},{backgroundPosition:`${s-d}px 0`}],{duration:s*h,iterations:1/0}).startTime=0}var qt=t=>[...t.querySelectorAll(`:scope > [${M}]`)],ft=4,Yt=t=>t.replace(/(\\d+(?:\\.\\d+)?)px/g,(e,r)=>{let o=parseFloat(r);return Number.isFinite(o)&&o<ft?`${ft}px`:`${o}px`});function St(t,e){let r=qt(t),o=t.getBoundingClientRect(),n={left:o.left+scrollX,top:o.top,width:o.width,height:o.height},c=bt(t);e.forEach((i,l)=>{let s=r[l];if(s||(s=document.createElement(\"div\"),s.style.cssText=\"position:absolute;display:block;pointer-events:none;background-repeat:no-repeat\",t.append(s)),s.setAttribute(M,i.type),Object.assign(s.style,{left:`${i.x}px`,top:`${i.y}px`,width:`${i.width}px`,height:`${i.height}px`,borderRadius:i.type===\"chrome\"?i.radius:Yt(i.radius)}),i.type===\"chrome\"){for(let h of _(s))h.cancel();s.style.backgroundImage=\"\",s.style.backgroundSize=\"\",s.style.backgroundRepeat=\"\";let d=i.chrome;s.style.background=d?.background??\"\",s.style.borderTop=d?.borderTop??\"\",s.style.borderRight=d?.borderRight??\"\",s.style.borderBottom=d?.borderBottom??\"\",s.style.borderLeft=d?.borderLeft??\"\",s.style.boxShadow=d?.boxShadow??\"\",s.dataset.motion=\"chrome\";return}s.dataset.motion===\"chrome\"&&(s.style.background=\"\",s.style.borderTop=\"\",s.style.borderRight=\"\",s.style.borderBottom=\"\",s.style.borderLeft=\"\",s.style.boxShadow=\"\");let a=`${Math.round(n.left+i.x)}|${Math.round(i.y)}|${Math.round(i.height)}|${Math.round(n.left)}|${Math.round(n.width)}|${Math.round(n.height)}|${document.documentElement.clientWidth}|${c.animation}|${c.duration}`;s.dataset.motion!==a&&(s.dataset.motion=a,Vt(s,n,c))});for(let i=r.length-1;i>=e.length;i--)r[i].remove()}var xt=t=>t.parentElement?`${xt(t.parentElement)} > :nth-child(${[...t.parentElement.children].indexOf(t)+1})`:\":root\";function v(t){let e=t?.previousElementSibling,r=e?.querySelector(`:scope > [${H}]`),o=e?.querySelector(`:scope > [${G}]`);if(!e||!r||!o)return;let n=typeof CSSStyleSheet==\"function\"&&\"replaceSync\"in CSSStyleSheet.prototype?new CSSStyleSheet:null;n&&(document.adoptedStyleSheets=[...document.adoptedStyleSheets,n],e[U]=()=>{document.adoptedStyleSheets=document.adoptedStyleSheets.filter(s=>s!==n)});let c=s=>n?.replaceSync(s.size?`${[...s].map(xt).join(\", \")} { visibility: hidden !important; }`:\"\"),i=()=>{if(!o.isConnected||e[z])return l.disconnect();r.getClientRects().length&&St(o,mt(r,o,{mark:!1,onCovered:c}))},l=new ResizeObserver(i);l.observe(e),document.fonts?.ready.then(i)}var Rt=self,yt=Symbol.for(X),Tt=Rt[yt];Rt[yt]=v;Array.isArray(Tt)&&Tt.forEach(v);v(document.currentScript);})();";
|
|
3
3
|
|
|
4
4
|
/** For every skeleton after a page's first: calls the boot INLINE_SCRIPT left on window. */
|
|
5
5
|
export const INLINE_STUB = "(s=>{let k=Symbol.for(\"a-smart-skeleton.boot\"),b=self[k];typeof b==\"function\"?b(s):(self[k]=b||[]).push(s)})(document.currentScript)";
|