situs-kit 0.1.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 ADDED
@@ -0,0 +1,15 @@
1
+ # ergon
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.3.7. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
@@ -0,0 +1,2 @@
1
+ function X(q,y){return typeof globalThis.getComputedStyle==="function"?globalThis.getComputedStyle(q,y??null):null}var P=1,u=2,Z=4,f="inline-block",I="nowrap",A="baseline",_="0px",g="block",E=/^\s+$/,p=/(\s+)/,r=",div,span,svg,img,br,hr,canvas,video,audio,iframe,input,textarea,select,button,picture,figure,",L={u:"underline",ins:"underline",s:"line-through",strike:"line-through",del:"line-through"};class i{dom;chars;words;lines;_o;_i;_j;_p;_k;_q;_b=[];_l=new Map;_f=null;_e=0;_g=!1;_a="";_c;_d;constructor(q,y={}){let z=typeof q==="string"?document.querySelector(q):q;if(!z)throw Error("SplitText: element not found");this.dom=z,this._o=z.innerHTML,this.chars=[],this.words=[],this.lines=[];let J=y.type?Array.isArray(y.type)?y.type:[y.type]:["chars","words","lines"],H=0;for(let M of J)if(M==="chars")H|=P;else if(M==="words")H|=u;else if(M==="lines")H|=Z;if(this._i=H,this._j=y.tag??"span",this._p=y.charsClass??"char",this._k=y.wordsClass??"word",this._q=y.linesClass??"line",this._c=y.style,this._d=y.class,this._t(),(y.resize??!0)&&H&Z)this._u()}_m(q,y){let z=document.createElement(this._j);if(z.className=q,z.style.display=f,y!==void 0)z.textContent=y;return z}_h(q,y,z,J){if(z){let{outer:H,inner:M}=z();if(M.appendChild(y),J)this._l.set(J,H);q.appendChild(H)}else q.appendChild(y)}_n(q,y,z){if(q.style.textDecoration=y,z)q.style.textDecorationColor=z}_t(){this._g=!0;let q=this.dom,y=X(q),z=y?parseFloat(y.letterSpacing)||0:0;if(this._a=y?y.textIndent:"",this._a&&this._a!==_)q.style.textIndent="0";let J=this._i,H=!!(J&P),M=!!(J&u),b=!!(J&Z),Q=M||b,U=new Map,V=(R)=>{for(let $ of Array.from(R.childNodes))if($.nodeType===1){let S=$.tagName.toLowerCase();if(L[S]){let G=X($)?.textDecorationColor;if(G)U.set($,G)}V($)}};V(q);let N=Array.from(q.childNodes),D=document.createDocumentFragment();q.replaceChildren();let v=(R,$,S,G)=>{if(R.nodeType===3){let K=(R.textContent??"").split(p);for(let Y of K){if(!Y)continue;if(E.test(Y)){D.appendChild(document.createTextNode(Y));continue}let F=Q?this._m(M?this._k:""):null;if(F){if(F.style.whiteSpace=I,S&&!H)this._n(F,S,G)}if(H){let j=[...Y];for(let T=0;T<j.length;T++){let k=this._m(this._p,j[T]);if(z&&T<j.length-1)k.style.marginRight=`${z}px`;if(S)this._n(k,S,G);if(this.chars.push(k),this._c?.chars)Object.assign(k.style,this._c.chars);if(this._d?.chars)k.classList.add(this._d.chars);if(F)F.appendChild(k)}if(!F)if($){let{outer:T,inner:k}=$();for(let h of this.chars.slice(-j.length))k.appendChild(h);D.appendChild(T)}else for(let T of this.chars.slice(-j.length))D.appendChild(T)}else if(F){if(F.textContent=Y,z)F.style.letterSpacing=`${z}px`}if(F){if(M){if(this.words.push(F),this._c?.words)Object.assign(F.style,this._c.words);if(this._d?.words)F.classList.add(this._d.words)}this._b.push(F),this._h(D,F,$,F)}else if(!H)this._h(D,document.createTextNode(Y),$)}return}if(R.nodeType!==1)return;let O=R,C=O.tagName.toLowerCase();if(r.includes(","+C+",")){let K=O.cloneNode(!0);if(S)this._n(K,S,G);let Y=X(O)?.verticalAlign;if(Y&&Y!==A)K.style.verticalAlign=Y;if(Q){let F=this._m(M?this._k:"");if(F.style.whiteSpace=I,Y&&Y!==A)F.style.verticalAlign=Y;if(F.appendChild(K),M){if(this.words.push(F),this._c?.words)Object.assign(F.style,this._c.words);if(this._d?.words)F.classList.add(this._d.words)}this._b.push(F),this._h(D,F,$,F)}else this._h(D,K,$);return}let W=()=>{let K=O.cloneNode(!1);if($){let{outer:Y,inner:F}=$();return F.appendChild(K),{outer:Y,inner:K}}return{outer:K,inner:K}},x=L[C],a=x?S?`${S} ${x}`:x:S,m=x?U.get(O)||G:G;for(let K of Array.from(O.childNodes))v(K,W,a,m)};for(let R of N)v(R,null,"","");q.appendChild(D);let B=!!(this._a&&this._a!==_);if(b)this._v(B);else if(B){let R=M?this.words[0]:H?this.chars[0]:null;if(R)R.style.marginLeft=this._a,q.style.textIndent="0"}this._g=!1}_v(q){if(q&&this._b[0])this._b[0].style.marginLeft=this._a;this._r();let y=[];if(typeof document.fonts?.status==="string"&&document.fonts.status!=="loaded")y.push(document.fonts.ready);let z=this.dom.querySelectorAll("img");for(let J=0;J<z.length;J++){let H=z[J];if(!H.complete)y.push(new Promise((M)=>{H.addEventListener("load",M,{once:!0}),H.addEventListener("error",M,{once:!0})}))}if(y.length){let J=this.dom.offsetHeight;Promise.all(y).then(()=>{if(this.dom.offsetHeight!==J)this.reflow()})}}_s(q){return this._l.get(q)??q}_r(){let q=this._b;if(!q.length)return;let y=q[0].offsetTop,z=y+q[0].offsetHeight,J=[],H=[];for(let Q of q){let U=Q.offsetTop,V=U+Q.offsetHeight;if(U<z&&V>y)y=Math.min(y,U),z=Math.max(z,V);else H.push(J),J=[],y=U,z=V;J.push(Q)}if(J.length)H.push(J);let M=!!(this._a&&this._a!==_);if(M&&q[0])q[0].style.marginLeft="";let b=document.createDocumentFragment();for(let Q=0;Q<H.length;Q++){let U=H[Q],V=document.createElement(this._j);if(V.className=this._q,V.style.display=g,Q===0&&M)V.style.paddingLeft=this._a;for(let N=0;N<U.length;N++){if(N>0)V.appendChild(document.createTextNode(" "));V.appendChild(this._s(U[N]))}if(this.lines.push(V),this._c?.lines)Object.assign(V.style,this._c.lines);if(this._d?.lines)V.classList.add(this._d.lines);b.appendChild(V)}this.dom.replaceChildren(b)}_u(){let q=this.dom.offsetParent?this.dom.offsetParent.offsetWidth:window.innerWidth,y=()=>{if(this._g)return;let J=this.dom.offsetParent,H=J?J.offsetWidth:window.innerWidth;if(H===q)return;if(q=H,this._e)cancelAnimationFrame(this._e);this._e=requestAnimationFrame(()=>this.reflow())};this._f=new ResizeObserver(y);let z=this.dom.offsetParent??this.dom.parentElement;if(z)this._f.observe(z);else this._f.observe(this.dom)}reflow(){if(!(this._i&Z)||this._g)return;let q=document.createDocumentFragment();for(let y=0;y<this._b.length;y++){if(y>0)q.appendChild(document.createTextNode(" "));q.appendChild(this._s(this._b[y]))}if(this.dom.replaceChildren(q),this.lines.length=0,this._a&&this._a!==_&&this._b[0])this._b[0].style.marginLeft=this._a;this._r()}revert(){this.destroy(),this.dom.innerHTML=this._o,this.chars.length=0,this.words.length=0,this._b.length=0,this._l.clear(),this.lines.length=0}destroy(){if(this._e)cancelAnimationFrame(this._e),this._e=0;if(this._f)this._f.disconnect(),this._f=null}}
2
+ export{i as a};
@@ -0,0 +1,2 @@
1
+ function C(z,q){return typeof globalThis.getComputedStyle==="function"?globalThis.getComputedStyle(z,q??null):null}var B=1,Y=2,S=4,I="inline-block",h="nowrap",f="baseline",L="0px",g="block",m="maskChar",E="maskWord",n="maskLine",s=/^\s+$/,w=/(\s+)/,o=",div,span,svg,img,br,hr,canvas,video,audio,iframe,input,textarea,select,button,picture,figure,",i={u:"underline",ins:"underline",s:"line-through",strike:"line-through",del:"line-through"};class d{dom;chars;words;lines;masks;_p;_k;_e;_h;_d=[];_l=new Map;_g=null;_f=0;_i=!1;_a="";_b;_c;constructor(z,q={}){let F=typeof z==="string"?document.querySelector(z):z;if(!F)throw Error("SplitText: element not found");this.dom=F,this._p=F.innerHTML,this.chars=[],this.words=[],this.lines=[],this.masks={chars:[],words:[],lines:[]};let $=q.type?Array.isArray(q.type)?q.type:[q.type]:["chars","words","lines"],V=0;for(let b of $)if(b==="chars")V|=B;else if(b==="words")V|=Y;else if(b==="lines")V|=S;this._k=V,this._h=q.tag??"span";let Q=0;if(q.mask===!0)Q=V;else if(Array.isArray(q.mask)){for(let b of q.mask)if(b==="chars")Q|=B;else if(b==="words")Q|=Y;else if(b==="lines")Q|=S}if(this._e=Q,this._b=q.style,this._c=q.class,this._t(),(q.resize??!0)&&V&S)this._u()}_m(z,q){let F=document.createElement(this._h);if(z)F.dataset[z]="";if(F.style.display=I,q!==void 0)F.textContent=q;return F}_q(z,q){let F=document.createElement(this._h);if(F.dataset[q]="",F.style.overflow="hidden",F.style.display=z,this._b?.mask)Object.assign(F.style,this._b.mask);if(this._c?.mask)F.classList.add(this._c.mask);return F}_o(z,q,F,$,V){if(this._e&q){let Q=this._q(F,$);return Q.appendChild(z),V.push(Q),Q}return z}_j(z,q,F,$){if(F){let{outer:V,inner:Q}=F();if(Q.appendChild(q),$)this._l.set($,V);z.appendChild(V)}else z.appendChild(q)}_n(z,q,F){if(z.style.textDecoration=q,F)z.style.textDecorationColor=F}_t(){this._i=!0;let z=this.dom,q=C(z),F=q?parseFloat(q.letterSpacing)||0:0;if(this._a=q?q.textIndent:"",this._a&&this._a!==L)z.style.textIndent="0";let $=this._k,V=!!($&B),Q=!!($&Y),b=!!($&S),u=Q||b,j=!!(this._e&B),X=new Map,U=(D)=>{for(let H of Array.from(D.childNodes))if(H.nodeType===1){let N=H.tagName.toLowerCase();if(i[N]){let O=C(H)?.textDecorationColor;if(O)X.set(H,O)}U(H)}};U(z);let Z=Array.from(z.childNodes),M=document.createDocumentFragment();z.replaceChildren();let k=(D,H,N,O)=>{if(D.nodeType===3){let T=(D.textContent??"").split(w);for(let G of T){if(!G)continue;if(s.test(G)){M.appendChild(document.createTextNode(G));continue}let J=u?this._m(Q?"word":""):null;if(J){if(J.style.whiteSpace=h,N&&!V)this._n(J,N,O)}if(V){let R=[...G],c=this.chars.length;for(let v=0;v<R.length;v++){let x=this._m("char",R[v]);if(F&&v<R.length-1)x.style.marginRight=`${F}px`;if(N)this._n(x,N,O);if(this.chars.push(x),this._b?.chars)Object.assign(x.style,this._b.chars);if(this._c?.chars)x.classList.add(this._c.chars);let y=j?this._o(x,B,I,m,this.masks.chars):x;if(J)J.appendChild(y)}if(!J){let v=H?H():null,x=v?v.inner:M;for(let y=c;y<this.chars.length;y++){let _=this.chars[y];x.appendChild(j&&_.parentElement?.dataset?.[m]!==void 0?_.parentElement:_)}if(v)M.appendChild(v.outer)}}else if(J){if(J.textContent=G,F)J.style.letterSpacing=`${F}px`}if(J){if(Q){if(this.words.push(J),this._b?.words)Object.assign(J.style,this._b.words);if(this._c?.words)J.classList.add(this._c.words)}this._d.push(J);let R=this._e&Y?this._o(J,Y,I,E,this.masks.words):J;this._j(M,R,H,J)}else if(!V)this._j(M,document.createTextNode(G),H)}return}if(D.nodeType!==1)return;let P=D,W=P.tagName.toLowerCase();if(o.includes(","+W+",")){let T=P.cloneNode(!0);if(N)this._n(T,N,O);let G=C(P)?.verticalAlign;if(G&&G!==f)T.style.verticalAlign=G;if(u){let J=this._m(Q?"word":"");if(J.style.whiteSpace=h,G&&G!==f)J.style.verticalAlign=G;if(J.appendChild(T),Q){if(this.words.push(J),this._b?.words)Object.assign(J.style,this._b.words);if(this._c?.words)J.classList.add(this._c.words)}this._d.push(J);let R=this._e&Y?this._o(J,Y,I,E,this.masks.words):J;this._j(M,R,H,J)}else this._j(M,T,H);return}let p=()=>{let T=P.cloneNode(!1);if(H){let{outer:G,inner:J}=H();return J.appendChild(T),{outer:G,inner:T}}return{outer:T,inner:T}},K=i[W],a=K?N?`${N} ${K}`:K:N,r=K?X.get(P)||O:O;for(let T of Array.from(P.childNodes))k(T,p,a,r)};for(let D of Z)k(D,null,"","");z.appendChild(M);let A=!!(this._a&&this._a!==L);if(b)this._v(A);else if(A){let D=Q?this.words[0]:V?this.chars[0]:null;if(D)D.style.marginLeft=this._a,z.style.textIndent="0"}this._i=!1}_v(z){if(z&&this._d[0])this._d[0].style.marginLeft=this._a;this._r();let q=[];if(typeof document.fonts?.status==="string"&&document.fonts.status!=="loaded")q.push(document.fonts.ready);let F=this.dom.querySelectorAll("img");for(let $=0;$<F.length;$++){let V=F[$];if(!V.complete)q.push(new Promise((Q)=>{V.addEventListener("load",Q,{once:!0}),V.addEventListener("error",Q,{once:!0})}))}if(q.length){let $=this.dom.offsetHeight;Promise.all(q).then(()=>{if(this.dom.offsetHeight!==$)this.reflow()})}}_s(z){return this._l.get(z)??z}_r(){let z=this._d;if(!z.length)return;let q=z[0].offsetTop,F=q+z[0].offsetHeight,$=[],V=[];for(let j of z){let X=j.offsetTop,U=X+j.offsetHeight;if(X<F&&U>q)q=Math.min(q,X),F=Math.max(F,U);else V.push($),$=[],q=X,F=U;$.push(j)}if($.length)V.push($);let Q=!!(this._a&&this._a!==L);if(Q&&z[0])z[0].style.marginLeft="";let b=!!(this._e&S),u=document.createDocumentFragment();for(let j=0;j<V.length;j++){let X=V[j],U=document.createElement(this._h);if(U.dataset.line="",U.style.display=g,j===0&&Q)U.style.paddingLeft=this._a;for(let Z=0;Z<X.length;Z++){if(Z>0)U.appendChild(document.createTextNode(" "));U.appendChild(this._s(X[Z]))}if(this.lines.push(U),this._b?.lines)Object.assign(U.style,this._b.lines);if(this._c?.lines)U.classList.add(this._c.lines);if(b){let Z=this._q(g,n);Z.appendChild(U),this.masks.lines.push(Z),u.appendChild(Z)}else u.appendChild(U)}this.dom.replaceChildren(u)}_u(){let z=this.dom.offsetParent?this.dom.offsetParent.offsetWidth:window.innerWidth,q=()=>{if(this._i)return;let $=this.dom.offsetParent,V=$?$.offsetWidth:window.innerWidth;if(V===z)return;if(z=V,this._f)cancelAnimationFrame(this._f);this._f=requestAnimationFrame(()=>this.reflow())};this._g=new ResizeObserver(q);let F=this.dom.offsetParent??this.dom.parentElement;if(F)this._g.observe(F);else this._g.observe(this.dom)}reflow(){if(!(this._k&S)||this._i)return;let z=document.createDocumentFragment();for(let q=0;q<this._d.length;q++){if(q>0)z.appendChild(document.createTextNode(" "));z.appendChild(this._s(this._d[q]))}if(this.dom.replaceChildren(z),this.lines.length=0,this.masks.lines.length=0,this._a&&this._a!==L&&this._d[0])this._d[0].style.marginLeft=this._a;this._r()}revert(){this.destroy(),this.dom.innerHTML=this._p,this.chars.length=0,this.words.length=0,this._d.length=0,this._l.clear(),this.lines.length=0,this.masks.chars.length=0,this.masks.words.length=0,this.masks.lines.length=0}destroy(){if(this._f)cancelAnimationFrame(this._f),this._f=0;if(this._g)this._g.disconnect(),this._g=null}}
2
+ export{d as a};
@@ -0,0 +1,2 @@
1
+ function X(q,y){return typeof globalThis.getComputedStyle==="function"?globalThis.getComputedStyle(q,y??null):null}var P=1,u=2,Z=4,f="inline-block",I="nowrap",A="baseline",_="0px",g="block",E=/^\s+$/,p=/(\s+)/,i=",div,span,svg,img,br,hr,canvas,video,audio,iframe,input,textarea,select,button,picture,figure,",L={u:"underline",ins:"underline",s:"line-through",strike:"line-through",del:"line-through"};class r{dom;chars;words;lines;_m;_g;_h;_n;_i;_o;_b=[];_j=new Map;_d=null;_c=0;_e=!1;_a="";constructor(q,y={}){let z=typeof q==="string"?document.querySelector(q):q;if(!z)throw Error("SplitText: element not found");this.dom=z,this._m=z.innerHTML,this.chars=[],this.words=[],this.lines=[];let J=y.type?Array.isArray(y.type)?y.type:[y.type]:["chars","words","lines"],F=0;for(let M of J)if(M==="chars")F|=P;else if(M==="words")F|=u;else if(M==="lines")F|=Z;if(this._g=F,this._h=y.tag??"span",this._n=y.charsClass??"char",this._i=y.wordsClass??"word",this._o=y.linesClass??"line",this._r(),(y.resize??!0)&&F&Z)this._s()}_k(q,y){let z=document.createElement(this._h);if(z.className=q,z.style.display=f,y!==void 0)z.textContent=y;return z}_f(q,y,z,J){if(z){let{outer:F,inner:M}=z();if(M.appendChild(y),J)this._j.set(J,F);q.appendChild(F)}else q.appendChild(y)}_l(q,y,z){if(q.style.textDecoration=y,z)q.style.textDecorationColor=z}_r(){this._e=!0;let q=this.dom,y=X(q),z=y?parseFloat(y.letterSpacing)||0:0;if(this._a=y?y.textIndent:"",this._a&&this._a!==_)q.style.textIndent="0";let J=this._g,F=!!(J&P),M=!!(J&u),b=!!(J&Z),Q=M||b,U=new Map,Y=(R)=>{for(let $ of Array.from(R.childNodes))if($.nodeType===1){let S=$.tagName.toLowerCase();if(L[S]){let G=X($)?.textDecorationColor;if(G)U.set($,G)}Y($)}};Y(q);let k=Array.from(q.childNodes),D=document.createDocumentFragment();q.replaceChildren();let v=(R,$,S,G)=>{if(R.nodeType===3){let K=(R.textContent??"").split(p);for(let V of K){if(!V)continue;if(E.test(V)){D.appendChild(document.createTextNode(V));continue}let H=Q?this._k(M?this._i:""):null;if(H){if(H.style.whiteSpace=I,S&&!F)this._l(H,S,G)}if(F){let j=[...V];for(let T=0;T<j.length;T++){let O=this._k(this._n,j[T]);if(z&&T<j.length-1)O.style.marginRight=`${z}px`;if(S)this._l(O,S,G);if(this.chars.push(O),H)H.appendChild(O)}if(!H)if($){let{outer:T,inner:O}=$();for(let h of this.chars.slice(-j.length))O.appendChild(h);D.appendChild(T)}else for(let T of this.chars.slice(-j.length))D.appendChild(T)}else if(H){if(H.textContent=V,z)H.style.letterSpacing=`${z}px`}if(H){if(M)this.words.push(H);this._b.push(H),this._f(D,H,$,H)}else if(!F)this._f(D,document.createTextNode(V),$)}return}if(R.nodeType!==1)return;let N=R,C=N.tagName.toLowerCase();if(i.includes(","+C+",")){let K=N.cloneNode(!0);if(S)this._l(K,S,G);let V=X(N)?.verticalAlign;if(V&&V!==A)K.style.verticalAlign=V;if(Q){let H=this._k(M?this._i:"");if(H.style.whiteSpace=I,V&&V!==A)H.style.verticalAlign=V;if(H.appendChild(K),M)this.words.push(H);this._b.push(H),this._f(D,H,$,H)}else this._f(D,K,$);return}let W=()=>{let K=N.cloneNode(!1);if($){let{outer:V,inner:H}=$();return H.appendChild(K),{outer:V,inner:K}}return{outer:K,inner:K}},x=L[C],a=x?S?`${S} ${x}`:x:S,m=x?U.get(N)||G:G;for(let K of Array.from(N.childNodes))v(K,W,a,m)};for(let R of k)v(R,null,"","");q.appendChild(D);let B=!!(this._a&&this._a!==_);if(b)this._t(B);else if(B){let R=M?this.words[0]:F?this.chars[0]:null;if(R)R.style.marginLeft=this._a,q.style.textIndent="0"}this._e=!1}_t(q){if(q&&this._b[0])this._b[0].style.marginLeft=this._a;this._p();let y=[];if(typeof document.fonts?.status==="string"&&document.fonts.status!=="loaded")y.push(document.fonts.ready);let z=this.dom.querySelectorAll("img");for(let J=0;J<z.length;J++){let F=z[J];if(!F.complete)y.push(new Promise((M)=>{F.addEventListener("load",M,{once:!0}),F.addEventListener("error",M,{once:!0})}))}if(y.length){let J=this.dom.offsetHeight;Promise.all(y).then(()=>{if(this.dom.offsetHeight!==J)this.reflow()})}}_q(q){return this._j.get(q)??q}_p(){let q=this._b;if(!q.length)return;let y=q[0].offsetTop,z=y+q[0].offsetHeight,J=[],F=[];for(let Q of q){let U=Q.offsetTop,Y=U+Q.offsetHeight;if(U<z&&Y>y)y=Math.min(y,U),z=Math.max(z,Y);else F.push(J),J=[],y=U,z=Y;J.push(Q)}if(J.length)F.push(J);let M=!!(this._a&&this._a!==_);if(M&&q[0])q[0].style.marginLeft="";let b=document.createDocumentFragment();for(let Q=0;Q<F.length;Q++){let U=F[Q],Y=document.createElement(this._h);if(Y.className=this._o,Y.style.display=g,Q===0&&M)Y.style.paddingLeft=this._a;for(let k=0;k<U.length;k++){if(k>0)Y.appendChild(document.createTextNode(" "));Y.appendChild(this._q(U[k]))}this.lines.push(Y),b.appendChild(Y)}this.dom.replaceChildren(b)}_s(){let q=this.dom.offsetParent?this.dom.offsetParent.offsetWidth:window.innerWidth,y=()=>{if(this._e)return;let J=this.dom.offsetParent,F=J?J.offsetWidth:window.innerWidth;if(F===q)return;if(q=F,this._c)cancelAnimationFrame(this._c);this._c=requestAnimationFrame(()=>this.reflow())};this._d=new ResizeObserver(y);let z=this.dom.offsetParent??this.dom.parentElement;if(z)this._d.observe(z);else this._d.observe(this.dom)}reflow(){if(!(this._g&Z)||this._e)return;let q=document.createDocumentFragment();for(let y=0;y<this._b.length;y++){if(y>0)q.appendChild(document.createTextNode(" "));q.appendChild(this._q(this._b[y]))}if(this.dom.replaceChildren(q),this.lines.length=0,this._a&&this._a!==_&&this._b[0])this._b[0].style.marginLeft=this._a;this._p()}revert(){this.destroy(),this.dom.innerHTML=this._m,this.chars.length=0,this.words.length=0,this._b.length=0,this._j.clear(),this.lines.length=0}destroy(){if(this._c)cancelAnimationFrame(this._c),this._c=0;if(this._d)this._d.disconnect(),this._d=null}}
2
+ export{r as a};
@@ -0,0 +1,2 @@
1
+ function v(z,q){return typeof globalThis.getComputedStyle==="function"?globalThis.getComputedStyle(z,q??null):null}var P=1,Z=2,x=4,u="inline-block",A="nowrap",W="baseline",k="0px",h="block",i=/^\s+$/,p=/(\s+)/,r=",div,span,svg,img,br,hr,canvas,video,audio,iframe,input,textarea,select,button,picture,figure,",g={u:"underline",ins:"underline",s:"line-through",strike:"line-through",del:"line-through"};class c{dom;chars;words;lines;masks;_o;_k;_p;_g;_d=[];_l=new Map;_f=null;_e=0;_h=!1;_a="";_b;_c;constructor(z,q={}){let F=typeof z==="string"?document.querySelector(z):z;if(!F)throw Error("SplitText: element not found");this.dom=F,this._o=F.innerHTML,this.chars=[],this.words=[],this.lines=[],this.masks={chars:[],words:[],lines:[]};let M=q.type?Array.isArray(q.type)?q.type:[q.type]:["chars","words","lines"],H=0;for(let R of M)if(R==="chars")H|=P;else if(R==="words")H|=Z;else if(R==="lines")H|=x;this._k=H,this._g=q.tag??"span";let V=0;if(q.mask===!0)V=H;else if(Array.isArray(q.mask)){for(let R of q.mask)if(R==="chars")V|=P;else if(R==="words")V|=Z;else if(R==="lines")V|=x}if(this._p=V,this._b=q.style,this._c=q.class,this._s(),(q.resize??!0)&&H&x)this._t()}_m(z,q){let F=document.createElement(this._g);if(z)F.dataset[z]="";if(F.style.display=u,q!==void 0)F.textContent=q;return F}_u(z){let q=document.createElement(this._g);if(q.dataset.mask="",q.style.overflow="hidden",q.style.display=z,this._b?.mask)Object.assign(q.style,this._b.mask);if(this._c?.mask)q.classList.add(this._c.mask);return q}_i(z,q,F,M){if(this._p&q){let H=this._u(F);return H.appendChild(z),M.push(H),H}return z}_j(z,q,F,M){if(F){let{outer:H,inner:V}=F();if(V.appendChild(q),M)this._l.set(M,H);z.appendChild(H)}else z.appendChild(q)}_n(z,q,F){if(z.style.textDecoration=q,F)z.style.textDecorationColor=F}_s(){this._h=!0;let z=this.dom,q=v(z),F=q?parseFloat(q.letterSpacing)||0:0;if(this._a=q?q.textIndent:"",this._a&&this._a!==k)z.style.textIndent="0";let M=this._k,H=!!(M&P),V=!!(M&Z),R=!!(M&x),D=V||R,T=new Map,Y=(G)=>{for(let Q of Array.from(G.childNodes))if(Q.nodeType===1){let K=Q.tagName.toLowerCase();if(g[K]){let b=v(Q)?.textDecorationColor;if(b)T.set(Q,b)}Y(Q)}};Y(z);let C=Array.from(z.childNodes),S=document.createDocumentFragment();z.replaceChildren();let B=(G,Q,K,b)=>{if(G.nodeType===3){let U=(G.textContent??"").split(p);for(let $ of U){if(!$)continue;if(i.test($)){S.appendChild(document.createTextNode($));continue}let J=D?this._m(V?"word":""):null;if(J){if(J.style.whiteSpace=A,K&&!H)this._n(J,K,b)}if(H){let O=[...$];for(let y=0;y<O.length;y++){let N=this._m("char",O[y]);if(F&&y<O.length-1)N.style.marginRight=`${F}px`;if(K)this._n(N,K,b);if(this.chars.push(N),this._b?.chars)Object.assign(N.style,this._b.chars);if(this._c?.chars)N.classList.add(this._c.chars);let X=this._i(N,P,u,this.masks.chars);if(J)J.appendChild(X)}if(!J)if(Q){let{outer:y,inner:N}=Q();for(let X of this.chars.slice(-O.length)){let a=X.parentElement?.dataset?.mask!==void 0?X.parentElement:X;N.appendChild(a)}S.appendChild(y)}else for(let y of this.chars.slice(-O.length)){let N=y.parentElement?.dataset?.mask!==void 0?y.parentElement:y;S.appendChild(N)}}else if(J){if(J.textContent=$,F)J.style.letterSpacing=`${F}px`}if(J){if(V){if(this.words.push(J),this._b?.words)Object.assign(J.style,this._b.words);if(this._c?.words)J.classList.add(this._c.words)}this._d.push(J);let O=this._i(J,Z,u,this.masks.words);this._j(S,O,Q,J)}else if(!H)this._j(S,document.createTextNode($),Q)}return}if(G.nodeType!==1)return;let j=G,L=j.tagName.toLowerCase();if(r.includes(","+L+",")){let U=j.cloneNode(!0);if(K)this._n(U,K,b);let $=v(j)?.verticalAlign;if($&&$!==W)U.style.verticalAlign=$;if(D){let J=this._m(V?"word":"");if(J.style.whiteSpace=A,$&&$!==W)J.style.verticalAlign=$;if(J.appendChild(U),V){if(this.words.push(J),this._b?.words)Object.assign(J.style,this._b.words);if(this._c?.words)J.classList.add(this._c.words)}this._d.push(J);let O=this._i(J,Z,u,this.masks.words);this._j(S,O,Q,J)}else this._j(S,U,Q);return}let m=()=>{let U=j.cloneNode(!1);if(Q){let{outer:$,inner:J}=Q();return J.appendChild(U),{outer:$,inner:U}}return{outer:U,inner:U}},_=g[L],f=_?K?`${K} ${_}`:_:K,E=_?T.get(j)||b:b;for(let U of Array.from(j.childNodes))B(U,m,f,E)};for(let G of C)B(G,null,"","");z.appendChild(S);let I=!!(this._a&&this._a!==k);if(R)this._v(I);else if(I){let G=V?this.words[0]:H?this.chars[0]:null;if(G)G.style.marginLeft=this._a,z.style.textIndent="0"}this._h=!1}_v(z){if(z&&this._d[0])this._d[0].style.marginLeft=this._a;this._q();let q=[];if(typeof document.fonts?.status==="string"&&document.fonts.status!=="loaded")q.push(document.fonts.ready);let F=this.dom.querySelectorAll("img");for(let M=0;M<F.length;M++){let H=F[M];if(!H.complete)q.push(new Promise((V)=>{H.addEventListener("load",V,{once:!0}),H.addEventListener("error",V,{once:!0})}))}if(q.length){let M=this.dom.offsetHeight;Promise.all(q).then(()=>{if(this.dom.offsetHeight!==M)this.reflow()})}}_r(z){return this._l.get(z)??z}_q(){let z=this._d;if(!z.length)return;let q=z[0].offsetTop,F=q+z[0].offsetHeight,M=[],H=[];for(let D of z){let T=D.offsetTop,Y=T+D.offsetHeight;if(T<F&&Y>q)q=Math.min(q,T),F=Math.max(F,Y);else H.push(M),M=[],q=T,F=Y;M.push(D)}if(M.length)H.push(M);let V=!!(this._a&&this._a!==k);if(V&&z[0])z[0].style.marginLeft="";let R=document.createDocumentFragment();for(let D=0;D<H.length;D++){let T=H[D],Y=document.createElement(this._g);if(Y.dataset.line="",Y.style.display=h,D===0&&V)Y.style.paddingLeft=this._a;for(let S=0;S<T.length;S++){if(S>0)Y.appendChild(document.createTextNode(" "));Y.appendChild(this._r(T[S]))}if(this.lines.push(Y),this._b?.lines)Object.assign(Y.style,this._b.lines);if(this._c?.lines)Y.classList.add(this._c.lines);let C=this._i(Y,x,h,this.masks.lines);R.appendChild(C)}this.dom.replaceChildren(R)}_t(){let z=this.dom.offsetParent?this.dom.offsetParent.offsetWidth:window.innerWidth,q=()=>{if(this._h)return;let M=this.dom.offsetParent,H=M?M.offsetWidth:window.innerWidth;if(H===z)return;if(z=H,this._e)cancelAnimationFrame(this._e);this._e=requestAnimationFrame(()=>this.reflow())};this._f=new ResizeObserver(q);let F=this.dom.offsetParent??this.dom.parentElement;if(F)this._f.observe(F);else this._f.observe(this.dom)}reflow(){if(!(this._k&x)||this._h)return;let z=document.createDocumentFragment();for(let q=0;q<this._d.length;q++){if(q>0)z.appendChild(document.createTextNode(" "));z.appendChild(this._r(this._d[q]))}if(this.dom.replaceChildren(z),this.lines.length=0,this.masks.lines.length=0,this._a&&this._a!==k&&this._d[0])this._d[0].style.marginLeft=this._a;this._q()}revert(){this.destroy(),this.dom.innerHTML=this._o,this.chars.length=0,this.words.length=0,this._d.length=0,this._l.clear(),this.lines.length=0,this.masks.chars.length=0,this.masks.words.length=0,this.masks.lines.length=0}destroy(){if(this._e)cancelAnimationFrame(this._e),this._e=0;if(this._f)this._f.disconnect(),this._f=null}}
2
+ export{c as a};
@@ -0,0 +1,2 @@
1
+ function B(q,y){return typeof globalThis.getComputedStyle==="function"?globalThis.getComputedStyle(q,y??null):null}var P=1,I=2,X=4,E="inline-block",A="nowrap",L="baseline",Z="0px",p=/^\s+$/,g=/(\s+)/,f=",div,span,svg,img,br,hr,canvas,video,audio,iframe,input,textarea,select,button,picture,figure,",u={u:"underline",ins:"underline",s:"line-through",strike:"line-through",del:"line-through"};class i{dom;chars;words;lines;_k;_g;_h;_l;_i;_m;_b=[];_f=new Map;_d=null;_c=0;_e=!1;_a="";constructor(q,y={}){let F=typeof q==="string"?document.querySelector(q):q;if(!F)throw Error("SplitText: element not found");this.dom=F,this._k=F.innerHTML,this.chars=[],this.words=[],this.lines=[];let J=y.type?Array.isArray(y.type)?y.type:[y.type]:["chars","words","lines"],H=0;for(let M of J)if(M==="chars")H|=P;else if(M==="words")H|=I;else if(M==="lines")H|=X;if(this._g=H,this._h=y.tag??"span",this._l=y.charsClass??"char",this._i=y.wordsClass??"word",this._m=y.linesClass??"line",this._p(),(y.resize??!0)&&H&X)this._q()}_j(q,y){let F=document.createElement(this._h);if(F.className=q,F.style.display=E,y!==void 0)F.textContent=y;return F}_p(){this._e=!0;let q=this.dom,y=B(q),F=y?parseFloat(y.letterSpacing)||0:0;if(this._a=y?y.textIndent:"",this._a&&this._a!==Z)q.style.textIndent="0";let J=this._g,H=!!(J&P),M=!!(J&I),j=!!(J&X),U=M||j,k=new Map,Q=(D)=>{for(let K of Array.from(D.childNodes))if(K.nodeType===1){let G=K.tagName.toLowerCase();if(u[G]){let T=B(K)?.textDecorationColor;if(T)k.set(K,T)}Q(K)}};Q(q);let O=Array.from(q.childNodes),S=document.createDocumentFragment();q.replaceChildren();let _=(D,K,G,T)=>{if(D.nodeType===3){let Y=(D.textContent??"").split(g);for(let $ of Y){if(!$)continue;if(p.test($)){S.appendChild(document.createTextNode($));continue}let z=U?this._j(M?this._i:""):null;if(z){if(z.style.whiteSpace=A,G&&!H){if(z.style.textDecoration=G,T)z.style.textDecorationColor=T}}if(H){let V=[...$];for(let R=0;R<V.length;R++){let N=this._j(this._l,V[R]);if(F&&R<V.length-1)N.style.marginRight=`${F}px`;if(G){if(N.style.textDecoration=G,T)N.style.textDecorationColor=T}if(this.chars.push(N),z)z.appendChild(N)}if(!z)if(K){let{outer:R,inner:N}=K();for(let h of this.chars.slice(-V.length))N.appendChild(h);S.appendChild(R)}else for(let R of this.chars.slice(-V.length))S.appendChild(R)}else if(z){if(z.textContent=$,F)z.style.letterSpacing=`${F}px`}if(z){if(M)this.words.push(z);if(this._b.push(z),K){let{outer:V,inner:R}=K();R.appendChild(z),this._f.set(z,V),S.appendChild(V)}else S.appendChild(z)}else if(!H){let V=document.createTextNode($);if(K){let{outer:R,inner:N}=K();N.appendChild(V),S.appendChild(R)}else S.appendChild(V)}}return}if(D.nodeType!==1)return;let b=D,C=b.tagName.toLowerCase();if(f.includes(","+C+",")){let Y=b.cloneNode(!0);if(G){if(Y.style.textDecoration=G,T)Y.style.textDecorationColor=T}let $=B(b)?.verticalAlign;if($&&$!==L)Y.style.verticalAlign=$;if(U){let z=this._j(M?this._i:"");if(z.style.whiteSpace=A,$&&$!==L)z.style.verticalAlign=$;if(z.appendChild(Y),M)this.words.push(z);if(this._b.push(z),K){let{outer:V,inner:R}=K();R.appendChild(z),this._f.set(z,V),S.appendChild(V)}else S.appendChild(z)}else if(K){let{outer:z,inner:V}=K();V.appendChild(Y),S.appendChild(z)}else S.appendChild(Y);return}let W=()=>{let Y=b.cloneNode(!1);if(K){let{outer:$,inner:z}=K();return z.appendChild(Y),{outer:$,inner:Y}}return{outer:Y,inner:Y}},x=u[C],a=x?G?`${G} ${x}`:x:G,m=x?k.get(b)||T:T;for(let Y of Array.from(b.childNodes))_(Y,W,a,m)};for(let D of O)_(D,null,"","");q.appendChild(S);let v=!!(this._a&&this._a!==Z);if(j)this._r(v);else if(v){let D=M?this.words[0]:H?this.chars[0]:null;if(D)D.style.marginLeft=this._a,q.style.textIndent="0"}this._e=!1}_r(q){if(q&&this._b[0])this._b[0].style.marginLeft=this._a;this._n();let y=[];if(typeof document.fonts?.status==="string"&&document.fonts.status!=="loaded")y.push(document.fonts.ready);let F=this.dom.querySelectorAll("img");for(let J=0;J<F.length;J++){let H=F[J];if(!H.complete)y.push(new Promise((M)=>{H.addEventListener("load",M,{once:!0}),H.addEventListener("error",M,{once:!0})}))}if(y.length){let J=this.dom.offsetHeight;Promise.all(y).then(()=>{if(this.dom.offsetHeight!==J)this.reflow()})}}_o(q){return this._f.get(q)??q}_n(){let q=this._b.length?this._b:Array.from(this.dom.children);if(!q.length)return;let y=q[0].offsetTop,F=y+q[0].offsetHeight,J=[],H=[];for(let U of q){let k=U.offsetTop,Q=k+U.offsetHeight;if(k<F&&Q>y)y=Math.min(y,k),F=Math.max(F,Q);else H.push(J),J=[],y=k,F=Q;J.push(U)}if(J.length)H.push(J);let M=!!(this._a&&this._a!==Z);if(M&&this._b[0])this._b[0].style.marginLeft="";let j=document.createDocumentFragment();for(let U=0;U<H.length;U++){let k=H[U],Q=document.createElement(this._h);if(Q.className=this._m,Q.style.display="block",U===0&&M)Q.style.paddingLeft=this._a;for(let O=0;O<k.length;O++){if(O>0)Q.appendChild(document.createTextNode(" "));Q.appendChild(this._o(k[O]))}this.lines.push(Q),j.appendChild(Q)}this.dom.replaceChildren(j)}_q(){let q=this.dom.offsetParent?this.dom.offsetParent.offsetWidth:window.innerWidth,y=()=>{if(this._e)return;let J=this.dom.offsetParent,H=J?J.offsetWidth:window.innerWidth;if(H===q)return;if(q=H,this._c)cancelAnimationFrame(this._c);this._c=requestAnimationFrame(()=>this.reflow())};this._d=new ResizeObserver(y);let F=this.dom.offsetParent??this.dom.parentElement;if(F)this._d.observe(F);else this._d.observe(this.dom)}reflow(){if(!(this._g&X)||this._e)return;let q=document.createDocumentFragment();for(let y=0;y<this._b.length;y++){if(y>0)q.appendChild(document.createTextNode(" "));q.appendChild(this._o(this._b[y]))}if(this.dom.replaceChildren(q),this.lines.length=0,this._a&&this._a!==Z&&this._b[0])this._b[0].style.marginLeft=this._a;this._n()}revert(){this.destroy(),this.dom.innerHTML=this._k,this.chars.length=0,this.words.length=0,this._b.length=0,this._f.clear(),this.lines.length=0}destroy(){if(this._c)cancelAnimationFrame(this._c),this._c=0;if(this._d)this._d.disconnect(),this._d=null}}
2
+ export{i as a};
@@ -0,0 +1,2 @@
1
+ /** Shorthand for `getComputedStyle`. Returns `null` when unavailable (e.g. SSR). */
2
+ export declare function gCS(el: Element, pseudo?: string | null): CSSStyleDeclaration | null;
@@ -0,0 +1 @@
1
+ export { SplitText, type SplitTextOptions, type SplitType, } from "./split-text/index.ts";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{a as b}from"./chunk-fqr7g8fv.js";export{b as SplitText};
@@ -0,0 +1,74 @@
1
+ export type SplitType = "chars" | "words" | "lines";
2
+ /** Valid ordered combinations of split types (chars → words → lines). */
3
+ export type SplitTypeOption = SplitType | ["chars"] | ["words"] | ["lines"] | ["chars", "words"] | ["chars", "lines"] | ["words", "lines"] | ["chars", "words", "lines"];
4
+ export interface SplitTextOptions {
5
+ type?: SplitTypeOption;
6
+ tag?: string;
7
+ mask?: boolean | SplitType[];
8
+ resize?: boolean;
9
+ style?: {
10
+ chars?: Partial<CSSStyleDeclaration>;
11
+ words?: Partial<CSSStyleDeclaration>;
12
+ lines?: Partial<CSSStyleDeclaration>;
13
+ mask?: Partial<CSSStyleDeclaration>;
14
+ };
15
+ class?: {
16
+ chars?: string;
17
+ words?: string;
18
+ lines?: string;
19
+ mask?: string;
20
+ };
21
+ }
22
+ type WF = () => {
23
+ outer: Node;
24
+ inner: HTMLElement;
25
+ };
26
+ export declare class SplitText {
27
+ readonly dom: HTMLElement;
28
+ readonly chars: HTMLElement[];
29
+ readonly words: HTMLElement[];
30
+ readonly lines: HTMLElement[];
31
+ readonly masks: {
32
+ chars: HTMLElement[];
33
+ words: HTMLElement[];
34
+ lines: HTMLElement[];
35
+ };
36
+ /** @internal */ _originalHTML: string;
37
+ /** @internal */ _mask: number;
38
+ /** @internal */ _maskFlags: number;
39
+ /** @internal */ _tag: string;
40
+ /** @internal */ _wordEls: HTMLElement[];
41
+ /** @internal */ _wrapperMap: Map<HTMLElement, HTMLElement>;
42
+ /** @internal */ _resizeObs: ResizeObserver | null;
43
+ /** @internal */ _rafId: number;
44
+ /** @internal */ _splitting: boolean;
45
+ /** @internal */ _textIndent: string;
46
+ /** @internal */ _styles: SplitTextOptions["style"];
47
+ /** @internal */ _classes: SplitTextOptions["class"];
48
+ constructor(element: HTMLElement | string, options?: SplitTextOptions);
49
+ /** @internal — create a styled inline-block element. */
50
+ _makeEl(dataAttr: string, text?: string): HTMLElement;
51
+ /** @internal — create a mask wrapper element. */
52
+ _makeMask(display: string, key: string): HTMLElement;
53
+ /** @internal — wrap element in mask if needed, return the outermost node. */
54
+ _wrapMask(el: HTMLElement, flag: number, display: string, key: string, maskArr: HTMLElement[]): HTMLElement;
55
+ /** @internal — append node into parent, optionally wrapping via factory. */
56
+ _append(parent: Node, node: Node, wf: WF | null, wordEl?: HTMLElement): void;
57
+ /** @internal — apply text-decoration + color to an element. */
58
+ _applyDeco(el: HTMLElement, td: string, dc: string): void;
59
+ /** @internal */
60
+ _doSplit(): void;
61
+ /** @internal — detect lines, then re-check after pending resources settle. */
62
+ _applyLines(hasIndent: boolean): void;
63
+ /** @internal */
64
+ _resolveWrapper(w: HTMLElement): HTMLElement;
65
+ /** @internal */
66
+ _detectLines(): void;
67
+ /** @internal */
68
+ _observeResize(): void;
69
+ /** Recalculate line groupings without re-splitting chars/words. */
70
+ reflow(): void;
71
+ revert(): void;
72
+ destroy(): void;
73
+ }
74
+ export {};
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-fqr7g8fv.js";export{a as SplitText};
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "situs-kit",
3
+ "version": "0.1.0",
4
+ "description": "A creative developer helper library",
5
+ "module": "./dist/index.js",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./split-text": {
15
+ "types": "./dist/split-text/index.d.ts",
16
+ "import": "./dist/split-text/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "scripts": {
23
+ "build": "bun build.ts && bunx tsc -p tsconfig.build.json",
24
+ "prepublishOnly": "bun run build",
25
+ "test": "bun test",
26
+ "dev": "bun run examples/serve.ts"
27
+ },
28
+ "devDependencies": {
29
+ "@types/bun": "latest"
30
+ },
31
+ "peerDependencies": {
32
+ "typescript": "^5"
33
+ }
34
+ }