situs-kit 0.2.5 → 0.2.6
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as L,e as a,f as r}from"./chunk-0t3a7kj5.js";var I=1,B=2,K=4,C="inline-block",f="nowrap",E="baseline",S="0px",
|
|
1
|
+
import{c as L,e as a,f as r}from"./chunk-0t3a7kj5.js";var I=1,B=2,K=4,C="inline-block",f="nowrap",E="baseline",S="0px",g="block",m="maskChar",p="maskWord",l="maskLine",t=/^\s+$/,e=/(\s+)/,c=",div,span,svg,img,br,hr,canvas,video,audio,iframe,input,textarea,select,button,picture,figure,",w={u:"underline",ins:"underline",s:"line-through",strike:"line-through",del:"line-through"};class i{dom;chars;words;lines;masks;_n;_k;_g;_j;_f=[];_o=new Map;_i=null;_h=0;_l=!1;_c="";_d;_e;_a;_b=null;constructor(z,J={}){let F;if(typeof z==="string"){let q=r(z);if(q.length>1)F=q;else{let $=q[0]??a(z);if(!$)throw Error("SplitText: element not found");F=$}}else F=z;if(J.children){if(Array.isArray(F)||typeof F==="object"&&F!==null&&"length"in F&&typeof F.item==="function")F=Array.from(F).flatMap((U)=>Array.from(U.children));else F=Array.from(F.children);let{children:q,...$}=J;J=$}if(Array.isArray(F)||typeof F==="object"&&F!==null&&"length"in F&&typeof F.item==="function"){let q=Array.from(F);if(q.length===0)throw Error("SplitText: empty element array");this._b=q.map(($)=>new i($,J)),this.dom=q,this.chars=this._b.flatMap(($)=>$.chars),this.words=this._b.flatMap(($)=>$.words),this.lines=this._b.flatMap(($)=>$.lines),this.masks={chars:this._b.flatMap(($)=>$.masks.chars),words:this._b.flatMap(($)=>$.masks.words),lines:this._b.flatMap(($)=>$.masks.lines)},this._n="",this._k=0,this._g=0,this._j="";return}let G=F;this._a=G,this.dom=G,this._n=G.innerHTML,this.chars=[],this.words=[],this.lines=[],this.masks={chars:[],words:[],lines:[]};let Q=J.type?Array.isArray(J.type)?J.type:[J.type]:["chars","words","lines"],Y=0;for(let q of Q)if(q==="chars")Y|=I;else if(q==="words")Y|=B;else if(q==="lines")Y|=K;this._k=Y,this._j=J.tag??"span";let D=0;if(J.mask===!0)D=Y;else if(Array.isArray(J.mask)){for(let q of J.mask)if(q==="chars")D|=I;else if(q==="words")D|=B;else if(q==="lines")D|=K}if(this._g=D,this._d=J.style,this._e=J.class,this._w(),(J.resize??!0)&&Y&K)this._x()}_p(z,J){let F=document.createElement(this._j);if(z)F.dataset[z]="";if(F.style.display=C,J!==void 0)F.textContent=J;return F}_s(z,J){let F=document.createElement(this._j);if(F.dataset[J]="",F.style.overflow="hidden",F.style.display=z,this._d?.mask)Object.assign(F.style,this._d.mask);if(this._e?.mask)F.classList.add(this._e.mask);return F}_r(z,J,F,H,G){if(this._g&J){let Q=this._s(F,H);return Q.appendChild(z),G.push(Q),Q}return z}_m(z,J,F,H){if(F){let{outer:G,inner:Q}=F();if(Q.appendChild(J),H)this._o.set(H,G);z.appendChild(G)}else z.appendChild(J)}_q(z,J,F){if(z.style.textDecoration=J,F)z.style.textDecorationColor=F}_w(){this._l=!0;let z=this._a,J=L(z),F=J?parseFloat(J.letterSpacing)||0:0;if(this._c=J?J.textIndent:"",this._c&&this._c!==S)z.style.textIndent="0";let H=this._k,G=!!(H&I),Q=!!(H&B),Y=!!(H&K),D=Q||Y,q=!!(this._g&I),$=new Map,U=new Set,O=(R)=>{for(let j of Array.from(R.childNodes))if(j.nodeType===1){let X=j.tagName.toLowerCase();if(w[X]){let b=L(j)?.textDecorationColor;if(b)$.set(j,b)}if(c.includes(","+X+",")&&L(j)?.display==="contents")U.add(j);O(j)}};O(z);let d=Array.from(z.childNodes),M=document.createDocumentFragment();z.replaceChildren();let W=(R,j,X,b)=>{if(R.nodeType===3){let Z=(R.textContent??"").split(e);for(let N of Z){if(!N)continue;if(t.test(N)){M.appendChild(document.createTextNode(N));continue}let V=D?this._p(Q?"word":""):null;if(V){if(V.style.whiteSpace=f,X&&!G)this._q(V,X,b)}if(G){let P=[...N],u=this.chars.length;for(let T=0;T<P.length;T++){let x=this._p("char",P[T]);if(F&&T<P.length-1)x.style.marginRight=`${F}px`;if(X)this._q(x,X,b);if(this.chars.push(x),this._d?.chars)Object.assign(x.style,this._d.chars);if(this._e?.chars)x.classList.add(this._e.chars);let y=q?this._r(x,I,C,m,this.masks.chars):x;if(V)V.appendChild(y)}if(!V){let T=j?j():null,x=T?T.inner:M;for(let y=u;y<this.chars.length;y++){let k=this.chars[y];x.appendChild(q&&k.parentElement?.dataset?.[m]!==void 0?k.parentElement:k)}if(T)M.appendChild(T.outer)}}else if(V){if(V.textContent=N,F)V.style.letterSpacing=`${F}px`}if(V){if(Q){if(this.words.push(V),this._d?.words)Object.assign(V.style,this._d.words);if(this._e?.words)V.classList.add(this._e.words)}this._f.push(V);let P=this._g&B?this._r(V,B,C,p,this.masks.words):V;this._m(M,P,j,V)}else if(!G)this._m(M,document.createTextNode(N),j)}return}if(R.nodeType!==1)return;let v=R,h=v.tagName.toLowerCase();if(c.includes(","+h+",")){if(U.has(v)){let V=M,P=document.createDocumentFragment();M=P;for(let T of Array.from(v.childNodes))W(T,j,X,b);M=V;let u=v.cloneNode(!1);u.appendChild(P),M.appendChild(u);return}let Z=v.cloneNode(!0);if(X)this._q(Z,X,b);let N=L(v)?.verticalAlign;if(N&&N!==E)Z.style.verticalAlign=N;if(D){let V=this._p(Q?"word":"");if(V.style.whiteSpace=f,N&&N!==E)V.style.verticalAlign=N;if(V.appendChild(Z),Q){if(this.words.push(V),this._d?.words)Object.assign(V.style,this._d.words);if(this._e?.words)V.classList.add(this._e.words)}this._f.push(V);let P=this._g&B?this._r(V,B,C,p,this.masks.words):V;this._m(M,P,j,V)}else this._m(M,Z,j);return}let s=()=>{let Z=v.cloneNode(!1);if(j){let{outer:N,inner:V}=j();return V.appendChild(Z),{outer:N,inner:Z}}return{outer:Z,inner:Z}},_=w[h],n=_?X?`${X} ${_}`:_:X,o=_?$.get(v)||b:b;for(let Z of Array.from(v.childNodes))W(Z,s,n,o)};for(let R of d)W(R,null,"","");z.appendChild(M);let A=!!(this._c&&this._c!==S);if(Y)this._y(A);else if(A){let R=Q?this.words[0]:G?this.chars[0]:null;if(R)R.style.marginLeft=this._c,z.style.textIndent="0"}this._l=!1}_y(z){if(z&&this._f[0])this._f[0].style.marginLeft=this._c;this._t();let J=[];if(typeof document.fonts?.status==="string"&&document.fonts.status!=="loaded")J.push(document.fonts.ready);let F=this._a.querySelectorAll("img");for(let H=0;H<F.length;H++){let G=F[H];if(!G.complete)J.push(new Promise((Q)=>{G.addEventListener("load",Q,{once:!0}),G.addEventListener("error",Q,{once:!0})}))}if(J.length){let H=this._a.offsetHeight===0&&this._a.parentElement?this._a.parentElement:this._a,G=H.offsetHeight;Promise.all(J).then(()=>{if(H.offsetHeight!==G)this.reflow()})}}_u(z){return this._o.get(z)??z}_t(){let z=this._f;if(!z.length)return;let J=z[0].offsetTop,F=J+z[0].offsetHeight,H=[],G=[];for(let q of z){let $=q.offsetTop,U=$+q.offsetHeight;if($<F&&U>J)J=Math.min(J,$),F=Math.max(F,U);else G.push(H),H=[],J=$,F=U;H.push(q)}if(H.length)G.push(H);let Q=!!(this._c&&this._c!==S);if(Q&&z[0])z[0].style.marginLeft="";let Y=!!(this._g&K),D=document.createDocumentFragment();for(let q=0;q<G.length;q++){let $=G[q],U=document.createElement(this._j);if(U.dataset.line="",U.style.display=g,q===0&&Q)U.style.paddingLeft=this._c;for(let O=0;O<$.length;O++){if(O>0)U.appendChild(document.createTextNode(" "));U.appendChild(this._u($[O]))}if(this.lines.push(U),this._d?.lines)Object.assign(U.style,this._d.lines);if(this._e?.lines)U.classList.add(this._e.lines);if(Y){let O=this._s(g,l);O.appendChild(U),this.masks.lines.push(O),D.appendChild(O)}else D.appendChild(U)}this._a.replaceChildren(D)}_x(){let z=this._a.offsetParent?this._a.offsetParent.offsetWidth:window.innerWidth,J=()=>{if(this._l)return;let H=this._a.offsetParent,G=H?H.offsetWidth:window.innerWidth;if(G===z)return;if(z=G,this._h)cancelAnimationFrame(this._h);this._h=requestAnimationFrame(()=>this.reflow())};this._i=new ResizeObserver(J);let F=this._a.offsetParent??this._a.parentElement;if(F)this._i.observe(F);else this._i.observe(this._a)}reflow(){if(this._b){this._b.forEach((J)=>J.reflow()),this._v();return}if(!(this._k&K)||this._l)return;let z=document.createDocumentFragment();for(let J=0;J<this._f.length;J++){if(J>0)z.appendChild(document.createTextNode(" "));z.appendChild(this._u(this._f[J]))}if(this._a.replaceChildren(z),this.lines.length=0,this.masks.lines.length=0,this._c&&this._c!==S&&this._f[0])this._f[0].style.marginLeft=this._c;this._t()}revert(){if(this._b){this._b.forEach((z)=>z.revert()),this._v();return}this.destroy(),this._a.innerHTML=this._n,this.chars.length=0,this.words.length=0,this._f.length=0,this._o.clear(),this.lines.length=0,this.masks.chars.length=0,this.masks.words.length=0,this.masks.lines.length=0}destroy(){if(this._b){this._b.forEach((z)=>z.destroy());return}if(this._h)cancelAnimationFrame(this._h),this._h=0;if(this._i)this._i.disconnect(),this._i=null}_v(){if(!this._b)return;this.chars.length=0,this.words.length=0,this.lines.length=0,this.masks.chars.length=0,this.masks.words.length=0,this.masks.lines.length=0;for(let z of this._b)this.chars.push(...z.chars),this.words.push(...z.words),this.lines.push(...z.lines),this.masks.chars.push(...z.masks.chars),this.masks.words.push(...z.masks.words),this.masks.lines.push(...z.masks.lines)}}
|
|
2
2
|
export{i as a};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
1
|
+
import{a as e}from"./chunk-bx1fe9dn.js";import{b as r}from"./chunk-s9ce6x50.js";import"./chunk-0t3a7kj5.js";import{g as t,h as o}from"./chunk-qjsknche.js";export{t as getDeltaFrame,o as Ticker,e as SplitText,r as SmoothScroll};
|
package/dist/split-text/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-bx1fe9dn.js";import"../chunk-0t3a7kj5.js";export{a as SplitText};
|