@fwkui/x-css 1.0.14 → 1.0.16
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 +168 -4
- package/dist/index-auto.d.mts +1 -1
- package/dist/index-auto.d.ts +1 -1
- package/dist/index-auto.js +130 -11
- package/dist/index-auto.js.map +1 -1
- package/dist/index-auto.mjs +130 -11
- package/dist/index-auto.mjs.map +1 -1
- package/dist/index.d.mts +34 -5
- package/dist/index.d.ts +34 -5
- package/dist/index.js +130 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,131 @@
|
|
|
1
|
-
var ne=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,s)=>(typeof require<"u"?require:n)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ye=e=>(e=e||new Map,{all:e,on(n,s){let r=e.get(n);r?r.push(s):e.set(n,[s])},off(n,s){let r=e.get(n);r&&(s?r.splice(r.indexOf(s)>>>0,1):e.set(n,[]))},emit(n,s){let r=e.get(n);r&&r.slice().forEach(S=>{S(s)});let u=e.get("*");u&&u.slice().forEach(S=>{S(n,s)})}});function De(e){return e>=97&&e<=122}function re(e){if(!e||e.length<2)return null;let n=0,s=e.length,r="",u=e.lastIndexOf("@");if(u>0){let C=e.lastIndexOf("]");(C===-1||u>C)&&(r=e.substring(u+1),s=u)}let S="",A="",$=e.indexOf(":",n);if($>0&&$<s){let C=e.substring(n,$);n=$+1,S=C}let T=n;for(;T<s;){let C=e.charCodeAt(T);if(C>=48&&C<=57)T++;else break}if(T>n&&(A=e.substring(n,T),n=T),n>=s)return null;if(e.charCodeAt(n)===38)return{mq:S,layer:A,prop:"&",val:e.substring(n+1,s),selector:r};if(e.charCodeAt(n)===91){let C=e.indexOf("]",n);if(C>n)return{mq:S,layer:A,prop:e.substring(n,C+1),val:"",selector:r}}let R=n;for(;R<s;){let C=e.charCodeAt(R);if(C===45||C===46){if(R+1<s){let O=e.charCodeAt(R+1);if(C===45&&O===45&&R>n||O>=48&&O<=57)break}R++;continue}if(!De(C))break;R++}if(R===n)return null;let m=e.substring(n,R),D=e.substring(R,s);return{mq:S,layer:A,prop:m,val:D,selector:r}}var se=e=>{if(!e||typeof e!="object")return null;let n=e,s=n.default&&typeof n.default=="object"?n.default:n,r=s.SHORT_PROPERTIES,u=s.COMMON_VALUES,S=s.SPECIFIC_VALUES;return!r||!u||!S||typeof r!="object"||typeof u!="object"||typeof S!="object"?null:{SHORT_PROPERTIES:r,COMMON_VALUES:u,SPECIFIC_VALUES:S}},ve=async e=>{let n=await import(e),s=se(n);if(!s)throw new Error(ge);return s},ge="XCSS: dictionary module must export SHORT_PROPERTIES, COMMON_VALUES and SPECIFIC_VALUES",Se=()=>{let e=typeof ne=="function"?ne:null;if(!e)return null;for(let n of["./dictionary.js","./dictionary"])try{let s=e(n),r=se(s);if(r)return r}catch{}return null},Ie=async()=>{let e=Se();if(e)return e;let n=["./dictionary.mjs","./dictionary.js","./dictionary"],s=null;for(let r of n)try{let u=await import(r),S=se(u);if(S)return S}catch(u){s=u}throw s||new Error(ge)},Ae=(e,n)=>{if(!e||typeof document>"u")return;n=n||"fwkui";let s=Array.from({length:24},(r,u)=>"l"+u);if(!e.querySelector('style[id="'+n+'"]')){let r=document.createElement("style");if(r.id=n,!(e instanceof ShadowRoot))document.head.append(r);else try{e.prepend(r)}catch{e.appendChild(r)}let u=`@layer ${s.join(", ")};`,S=setInterval(()=>{if(r.sheet){clearInterval(S);try{r.sheet.insertRule(u,r.sheet.cssRules.length)}catch{}}},10)}},Oe=e=>{let n=Array.isArray(e.excludes)?e.excludes:Array.isArray(e.exclude)?e.exclude:[],s=JSON.stringify({base:e.base||"",aliases:e.aliases||{},breakpoints:e.breakpoints||[],theme:e.theme||{},prefix:e.prefix||"",excludes:n,excludePrefixes:e.excludePrefixes||[],dictionaryImport:e.dictionaryImport??!0}),r=0;if(s.length===0)return r.toString();for(let u=0;u<s.length;u++){let S=s.charCodeAt(u);r=(r<<5)-r+S,r|=0}return r.toString()},q="xcss_cache_v1",oe=(e={base:"",aliases:{},excludes:[],excludePrefixes:[],breakpoints:[],theme:{},prefix:"",dictionaryImport:!0})=>{let{base:n=null,breakpoints:s=[],aliases:r={},theme:u={},excludes:S=[],exclude:A=[],excludePrefixes:$=[],prefix:T="",dictionaryImport:R=!0}=e||{};Array.isArray(s)||(s=[]),Array.isArray(S)||(S=[]),Array.isArray(A)||(A=[]),Array.isArray($)||($=[]),(!r||typeof r!="object")&&(r={}),(!u||typeof u!="object")&&(u={});let m=[...S,...A],D=$.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0),C=t=>{let o=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+o.replace(/\*/g,".*")+"$")},O=m.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0).map(t=>{if(t.includes("*")){let o=C(t);return c=>o.test(c)}return o=>o===t}),L=t=>D.some(o=>t.startsWith(o))?!0:O.some(o=>o(t)),J=t=>!(T&&!t.startsWith(T)||L(t)),v={},H={},z={},Y={},le=()=>{Y={...z,...u}},_=t=>{if(!t){v={},H={},z={},le();return}v=t.SHORT_PROPERTIES,H=t.SPECIFIC_VALUES,z=t.COMMON_VALUES,le()},X=!0,F=Promise.resolve();if(R===!1)_(null);else if(typeof R=="string")X=!1,_(null),F=ve(R).then(t=>{_(t)}).catch(t=>{console.warn("XCSS: Failed to import dictionary from URL",t)}).finally(()=>{X=!0});else{let t=Se();t?_(t):(X=!1,_(null),F=Ie().then(o=>{_(o)}).catch(o=>{console.warn("XCSS: Failed to load built-in dictionary module",o)}).finally(()=>{X=!0}))}let he=(t=typeof document<"u"?document:void 0)=>{let o=typeof window<"u"&&typeof document<"u",c=null;t&&(c="getRootNode"in t?t.getRootNode():t);let x=new Map;o&&c&&Ae(c);let h=ye(),w=[{default:""},{xs:"screen and (max-width: 575px)"},{sm:"screen and (min-width: 576px)"},{md:"screen and (min-width: 768px)"},{lg:"screen and (min-width: 992px)"},{xl:"screen and (min-width: 1200px)"},{"2xl":"screen and (min-width: 1400px)"},{sma:"screen and (max-width: 768px)"},{mda:"screen and (max-width: 992px)"},{lga:"screen and (max-width: 1200px)"},{xla:"screen and (max-width: 1400px)"},...s],E=w.filter((l,i)=>w.findLastIndex(a=>Object.keys(a)[0]==Object.keys(l)[0])==i),d=E.map(l=>Object.keys(l)[0]),y={},f={},b={root:""},I={root:[]},j={root:!1},V=Oe(e),K=null,Z=!1,Ee=l=>{if(!(!o||!window.localStorage))try{localStorage.setItem(q,JSON.stringify(l))}catch(i){console.warn("XCSS: Failed to save cache",i)}},ce=()=>{o&&(K&&clearTimeout(K),K=setTimeout(()=>{let l={};for(let g in y)l[g]=Array.from(y[g]);let i={};Object.keys(b).forEach(g=>{if(g==="root")i[g]=b[g];else{let p=w.find(P=>Object.keys(P)[0]===g)?.[g];p&&b[g]?i[g]=`@media ${p} {
|
|
2
|
-
${
|
|
3
|
-
}`:
|
|
4
|
-
`),
|
|
5
|
-
`:"")+
|
|
6
|
-
`),
|
|
7
|
-
`:"")+
|
|
8
|
-
`),
|
|
9
|
-
${
|
|
10
|
-
}`:
|
|
11
|
-
`)}};function
|
|
1
|
+
var we=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var je=e=>(e=e||new Map,{all:e,on(t,n){let s=e.get(t);s?s.push(n):e.set(t,[n])},off(t,n){let s=e.get(t);s&&(n?s.splice(s.indexOf(n)>>>0,1):e.set(t,[]))},emit(t,n){let s=e.get(t);s&&s.slice().forEach(d=>{d(n)});let o=e.get("*");o&&o.slice().forEach(d=>{d(t,n)})}});function ot(e,t,n){let s=0;for(let o=t;o<n;o++){let d=e.charCodeAt(o);if(d===91){s++;continue}if(d===93){s>0&&s--;continue}if(d===58&&s===0)return o}return-1}function it(e,t,n){let s=0;for(let o=n-1;o>=t;o--){let d=e.charCodeAt(o);if(d===93){s++;continue}if(d===91){s>0&&s--;continue}if(d===64&&s===0)return o}return-1}function at(e,t,n){let s=0;for(let o=t;o<n;o++){let d=e.charCodeAt(o);if(d===91){s++;continue}if(d===93){if(s===0)return!1;s--}}return s===0}function ct(e){return e>=97&&e<=122}function ce(e){if(!e||e.length<2||!at(e,0,e.length))return null;let t=0,n=e.length,s="",o=it(e,t,n);o>t&&(s=e.substring(o+1,n),n=o);let d="",C="",g=ot(e,t,n);if(g>0&&g<n){let R=e.substring(t,g);t=g+1,d=R}let _=t;for(;_<n;){let R=e.charCodeAt(_);if(R>=48&&R<=57)_++;else break}if(_>t&&(C=e.substring(t,_),t=_),t>=n||e.charCodeAt(t)===38)return null;if(e.charCodeAt(t)===91){let R=e.indexOf("]",t);if(R>t)return{mq:d,layer:C,prop:e.substring(t,R+1),val:"",selector:s}}let E=t;for(;E<n;){let R=e.charCodeAt(E);if(R===45||R===46){if(E+1<n){let x=e.charCodeAt(E+1);if(R===45&&x===45&&E>t||x>=48&&x<=57)break}E++;continue}if(!ct(R))break;E++}if(E===t)return null;let re=e.substring(t,E),B=e.substring(E,n);return{mq:d,layer:C,prop:re,val:B,selector:s}}var N="xcss_cache_v1",He=e=>{let t=typeof e?.styleId=="string"&&e.styleId.trim()?e.styleId.trim():"fwkui",n=typeof e?.version=="string"&&e.version.trim()?e.version.trim():"v1",s=e?.compression??!0,o=typeof e?.debounceMs=="number"&&e.debounceMs>=0?e.debounceMs:1e3;return{styleId:t,version:n,compression:s,debounceMs:o}},lt=e=>`${e.styleId}_cache_${e.version}`,We=e=>{if(!e||typeof e!="object")return!1;let t=e;return t.__xcss_cache_v===2&&t.compressed===!0&&typeof t.payload=="string"},ve=e=>{if(!e||typeof e!="object")return!1;let t=e;return t.__xcss_cache_v===3&&t.compressed===!0&&t.algorithm==="deflate-raw"&&t.encoding==="base64"&&typeof t.payload=="string"},Ue=()=>typeof CompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u",Ve=()=>typeof DecompressionStream<"u"&&typeof Blob<"u"&&typeof Response<"u",dt=e=>{if(typeof btoa=="function"){let n="";for(let o=0;o<e.length;o+=32768){let d=e.subarray(o,o+32768);for(let C=0;C<d.length;C++)n+=String.fromCharCode(d[C])}return btoa(n)}let t=globalThis.Buffer;if(typeof t<"u")return t.from(e).toString("base64");throw new Error("XCSS: base64 encoding is not supported in this runtime")},ut=e=>{if(typeof atob=="function"){let n=atob(e),s=new Uint8Array(n.length);for(let o=0;o<n.length;o++)s[o]=n.charCodeAt(o);return s}let t=globalThis.Buffer;if(typeof t<"u")return new Uint8Array(t.from(e,"base64"));throw new Error("XCSS: base64 decoding is not supported in this runtime")},ft=async e=>{if(!Ue())throw new Error("XCSS: CompressionStream is not supported");let t=new Blob([e]).stream().pipeThrough(new CompressionStream("deflate-raw")),n=await new Response(t).arrayBuffer();return dt(new Uint8Array(n))},pt=async e=>{if(!Ve())throw new Error("XCSS: DecompressionStream is not supported");let t=ut(e),n=new Uint8Array(t.length);n.set(t);let s=new Blob([n.buffer]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return await new Response(s).text()},yt=e=>{try{let t=JSON.parse(e);return ve(t)}catch{return!1}},gt=e=>{if(!e)return"";let t=new Map,n=[],s=256;for(let d=0;d<256;d++)t.set(String.fromCharCode(d),d);let o=e[0];for(let d=1;d<e.length;d++){let C=e[d],g=o+C;t.has(g)?o=g:(n.push(t.get(o)),t.set(g,s++),o=C)}return n.push(t.get(o)),n.map(d=>String.fromCharCode(d)).join("")},Ne=e=>{if(!e)return"";let t=new Map,n=256,s="";for(let g=0;g<256;g++)t.set(g,String.fromCharCode(g));let o=e.split("").map(g=>g.charCodeAt(0)),d=o[0],C=t.get(d)||"";s=C;for(let g=1;g<o.length;g++){let _=o[g],E=t.get(_);E||(E=_===n?C+C[0]:""),s+=E,t.set(n++,C+E[0]),C=E}return s},Ee=e=>{if(!e||typeof e!="object")return null;let t=e,n=t.default&&typeof t.default=="object"?t.default:t,s=n.SHORT_PROPERTIES,o=n.COMMON_VALUES,d=n.SPECIFIC_VALUES;return!s||!o||!d||typeof s!="object"||typeof o!="object"||typeof d!="object"?null:{SHORT_PROPERTIES:s,COMMON_VALUES:o,SPECIFIC_VALUES:d}},St=async e=>{let t=await import(e),n=Ee(t);if(!n)throw new Error(qe);return n},qe="XCSS: dictionary module must export SHORT_PROPERTIES, COMMON_VALUES and SPECIFIC_VALUES",Fe=()=>{let e=typeof we=="function"?we:null;if(!e)return null;for(let t of["./dictionary.js","./dictionary"])try{let n=e(t),s=Ee(n);if(s)return s}catch{}return null},ht=async()=>{let e=Fe();if(e)return e;let t=["./dictionary.mjs","./dictionary.js","./dictionary"],n=null;for(let s of t)try{let o=await import(s),d=Ee(o);if(d)return d}catch(o){n=o}throw n||new Error(qe)},mt=(e,t)=>{if(!e||typeof document>"u")return;t=t||"fwkui";let n=Array.from({length:24},(s,o)=>"l"+o);if(!e.querySelector('style[id="'+t+'"]')){let s=document.createElement("style");if(s.id=t,!(e instanceof ShadowRoot))document.head.append(s);else try{e.prepend(s)}catch{e.appendChild(s)}let o=`@layer ${n.join(", ")};`,d=setInterval(()=>{if(s.sheet){clearInterval(d);try{s.sheet.insertRule(o,s.sheet.cssRules.length)}catch{}}},10)}},Ct=e=>{let t=Array.isArray(e.excludes)?e.excludes:Array.isArray(e.exclude)?e.exclude:[],n=He(e.cache),s=JSON.stringify({base:e.base||"",aliases:e.aliases||{},breakpoints:e.breakpoints||[],theme:e.theme||{},prefix:e.prefix||"",excludes:t,excludePrefixes:e.excludePrefixes||[],dictionaryImport:e.dictionaryImport??!0,cache:n}),o=0;if(s.length===0)return o.toString();for(let d=0;d<s.length;d++){let C=s.charCodeAt(d);o=(o<<5)-o+C,o|=0}return o.toString()},xe=e=>{if(!e)return null;try{let t=JSON.parse(e);if(We(t)){let n=Ne(t.payload);return n?JSON.parse(n):null}return ve(t)?null:t}catch{return null}},bt=async e=>{if(!e)return null;try{let t=JSON.parse(e);if(We(t)){let n=Ne(t.payload);return n?JSON.parse(n):null}if(ve(t)){let n=await pt(t.payload);return n?JSON.parse(n):null}return t}catch{return null}},Be=(e,t)=>{if(e==="root")return t;let n=/@media[^{]+\{\n?([\s\S]+)\n?\}/.exec(t);return n&&n[1]?n[1].trim():t},Re=(e={base:"",aliases:{},excludes:[],excludePrefixes:[],breakpoints:[],theme:{},prefix:"",dictionaryImport:!0,cache:{styleId:"fwkui",version:"v1",compression:!0,debounceMs:1e3}})=>{let{base:t=null,breakpoints:n=[],aliases:s={},theme:o={},excludes:d=[],exclude:C=[],excludePrefixes:g=[],prefix:_="",dictionaryImport:E=!0,cache:re={}}=e||{};Array.isArray(n)||(n=[]),Array.isArray(d)||(d=[]),Array.isArray(C)||(C=[]),Array.isArray(g)||(g=[]),(!s||typeof s!="object")&&(s={}),(!o||typeof o!="object")&&(o={});let B=He(re),R=lt(B),x=[...d,...C],X=g.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0),Y=r=>{let i=r.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return new RegExp("^"+i.replace(/\*/g,".*")+"$")},le=x.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0).map(r=>{if(r.includes("*")){let i=Y(r);return l=>i.test(l)}return i=>i===r}),De=r=>X.some(i=>r.startsWith(i))?!0:le.some(i=>i(r)),ke=r=>!(De(r)||_&&!r.startsWith(_)),Ze=["default","xs","sm","md","lg","xl","2xl","sma","mda","lga","xla"],Je=n.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r)).map(r=>Object.keys(r)[0]).filter(r=>typeof r=="string"&&r.length>0),ze=new Set([...Ze,...Je]),de=r=>!r||ze.has(r),Ye=E!==!1,Ge=new Set(["mx","my","px","py","bdx","bdy"]),ue=new Set,fe=r=>r?!Ye||!U||Object.keys(U).length===0?!0:!!U[r]||Ge.has(r)||ue.has(r):!1,U={},ne={},pe={},ye={},Oe=()=>{ye={...pe,...o}},q=r=>{if(!r){U={},ne={},pe={},ue=new Set,Oe();return}U=r.SHORT_PROPERTIES,ne=r.SPECIFIC_VALUES,pe=r.COMMON_VALUES,ue=new Set(Object.values(U)),Oe()},F=!0,se=Promise.resolve();if(E===!1)q(null);else if(typeof E=="string")F=!1,q(null),se=St(E).then(r=>{q(r)}).catch(r=>{console.warn("XCSS: Failed to import dictionary from URL",r)}).finally(()=>{F=!0});else{let r=Fe();r?q(r):(F=!1,q(null),se=ht().then(i=>{q(i)}).catch(i=>{console.warn("XCSS: Failed to load built-in dictionary module",i)}).finally(()=>{F=!0}))}let G=null,Qe=(r=typeof document<"u"?document:void 0)=>{let i=typeof window<"u"&&typeof document<"u",l=null,h=Array.isArray(t)?t.length>0:!!t;r&&(l="getRootNode"in r?r.getRootNode():r);let p=new Map;i&&l&&mt(l,B.styleId);let v=je(),I=[{default:""},{xs:"screen and (max-width: 575px)"},{sm:"screen and (min-width: 576px)"},{md:"screen and (min-width: 768px)"},{lg:"screen and (min-width: 992px)"},{xl:"screen and (min-width: 1200px)"},{"2xl":"screen and (min-width: 1400px)"},{sma:"screen and (max-width: 768px)"},{mda:"screen and (max-width: 992px)"},{lga:"screen and (max-width: 1200px)"},{xla:"screen and (max-width: 1400px)"},...n],y=I.filter((a,u)=>I.findLastIndex(c=>Object.keys(c)[0]==Object.keys(a)[0])==u),w=y.map(a=>Object.keys(a)[0]),f={},T={},m={root:""},$={root:[]},M={root:!1},Q=Ct(e),Z=null,A=0,K=!1,k=null,J=null,H=[],L=a=>{try{window.localStorage.setItem(R,a)}catch(u){console.warn("XCSS: Failed to save cache",u)}},oe=(a,u)=>{!i||!window.localStorage||typeof u=="string"&&window.localStorage.getItem(a)!==u||window.localStorage.removeItem(a)},V=a=>{if(!i||!window.localStorage)return;G=a;let u=++A;try{let c=JSON.stringify(a),S=()=>{let b={__xcss_cache_v:2,compressed:!0,payload:gt(c)};L(JSON.stringify(b))};if(!B.compression){L(c);return}if(Ue()&&Ve()){ft(c).then(b=>{if(u!==A)return;L(JSON.stringify({__xcss_cache_v:3,compressed:!0,algorithm:"deflate-raw",encoding:"base64",payload:b}))}).catch(()=>{u===A&&S()});return}S()}catch(c){console.warn("XCSS: Failed to save cache",c)}},ie=()=>{i&&(Z&&clearTimeout(Z),Z=setTimeout(()=>{let a={};for(let S in f)a[S]=Array.from(f[S]);let u={};Object.keys(m).forEach(S=>{if(S==="root")u[S]=m[S];else{let b=I.find(P=>Object.keys(P)[0]===S)?.[S];b&&m[S]?u[S]=`@media ${b} {
|
|
2
|
+
${m[S]}
|
|
3
|
+
}`:u[S]=m[S]||""}});let c={configHash:Q,cssText:u,rulesSet:a,keys:Array.from(p.entries())};V(c)},B.debounceMs))};if(i&&window.localStorage)try{let a=R===N?[R]:[R,N];for(let u of a){let c=window.localStorage.getItem(u);if(!c)continue;let S=xe(c);if(!S){if(yt(c)){H.push({key:u,raw:c});continue}window.localStorage.removeItem(u);continue}if(S.configHash!==Q){window.localStorage.removeItem(u);continue}k=S,J=u,K=!0;break}if(k){if(k.keys&&k.keys.forEach(([u,c])=>p.set(u,c)),k.cssText)for(let u in k.cssText){let c=k.cssText[u];m[u]=Be(u,c)}G=k}}catch(a){console.error(a)}i&&(T.root=new CSSStyleSheet),w.forEach(a=>{if(f[a]=new Set,i){let u=y.find(c=>Object.keys(c)[0]==a)?.[a]||"";T[a]=new CSSStyleSheet({media:u})}K||(m[a]=""),$[a]=[],M[a]=!1});let D=()=>{if(!l)return;let a=l.querySelector(`style[id="${B.styleId}"]`);a&&a.remove()},ae=(a,u)=>{if(a.keys&&a.keys.forEach(([c,S])=>p.set(c,S)),a.cssText)for(let c in a.cssText){if(c==="root"&&h)continue;let S=Be(c,a.cssText[c]);m[c]=S,i&&T[c]&&T[c].replaceSync(S)}if(a.rulesSet)for(let c in a.rulesSet)f[c]||(f[c]=new Set),a.rulesSet[c].forEach(S=>f[c].add(S));i&&window.localStorage&&u===N&&R!==N&&(V(a),window.localStorage.removeItem(N)),G=a,D()};K&&k&&ae(k,J),t&&Array.isArray(t)?(m.root=t.join(`
|
|
4
|
+
`),i&&T.root&&T.root.replaceSync(m.root)):(m.root=t||"",i&&T.root&&T.root.replaceSync(m.root)),i&&l&&["root",...w].forEach(a=>{T[a]&&l?.adoptedStyleSheets&&(l.adoptedStyleSheets.includes(T[a])||(l.adoptedStyleSheets=[...l.adoptedStyleSheets,T[a]]))}),i&&window.localStorage&&H.length>0&&(async()=>{for(let a of H){let u=await bt(a.raw);if(!u){oe(a.key,a.raw);continue}if(u.configHash!==Q){oe(a.key,a.raw);continue}if(!K){K=!0,k=u,J=a.key,ae(u,a.key);break}}})();let he=(a,u)=>{let{media:c,property:S,selector:b,layer:P,className:O}=u,W=m,j=$,Ce=M;P=Number(P)||0;let Ke=p.get(a),st=Ke?`.${Ke}${b}`:`.${O}${b}`;var be=`@layer l${P}{${st}{${S}}}`;f[c]||(f[c]=new Set);let Me=f[c];if(!Me.has(be))if(Me.add(be),j[c]||(j[c]=[]),j[c].push(be),i)Ce[c]||(Ce[c]=!0,queueMicrotask(()=>{let te=j[c],Le=T[c];te.length>0&&(W[c]+=(W[c]?`
|
|
5
|
+
`:"")+te.join(`
|
|
6
|
+
`),Le&&Le.replaceSync(W[c]),j[c]=[],ie()),Ce[c]=!1}));else{let te=j[c];te.length>0&&(W[c]+=(W[c]?`
|
|
7
|
+
`:"")+te.join(`
|
|
8
|
+
`),j[c]=[])}},me=a=>{a.forEach(u=>{let c=$e(u);c&&he(u,c)})},ee=a=>{if(a.length===0)return;let u=()=>me(a);F?u():se.then(u)};return v.on("observeDom",ee),{clsx:(...a)=>{let u=a.map(b=>Array.isArray(b)?b:[b]).flat(1/0).map(b=>typeof b=="string"?b.split(/(\s|\t)+/g):[]).flat(1/0);u=u.filter(b=>typeof b=="string"&&b.trim()),u=[...new Set(u)];let c=b=>{if(!ke(b))return!1;if(F)return!!$e(b);let P=_?b.slice(_.length):b,O=ce(P);if(!O||!de(O.mq))return!1;let W=(O.selector||"").replace(/(';|;)/g,j=>j=="';"?";":" ");return W&&!ge(W)?!1:O.prop.startsWith("[")?!!Xe(O.prop+O.val):fe(O.prop)?(O.prop==="&",O.val.length>0):!1},S=u.map(b=>{let P=b;if(p.has(b))P=p.get(b);else if(c(b)){let O="D"+p.size.toString(32).toUpperCase();p.set(b,O),P=O,ie()}return P});return i?queueMicrotask(()=>v.emit("observeDom",u)):v.emit("observeDom",u),S.join(" ")},observe:()=>{!i||!l||nt(l,a=>{ee(a)})},getCssString:()=>Object.entries(m).map(([a,u])=>{if(!u)return"";if(a==="root"||a==="default")return u;let c=I.find(S=>Object.keys(S)[0]===a)?.[a];return c?`@media ${c} {
|
|
9
|
+
${u}
|
|
10
|
+
}`:u}).join(`
|
|
11
|
+
`)}};function Xe(r){let i=new RegExp("^(\\[(?<p>[a-zA-Z]+)\\])$"),{p:l=""}=i.exec(r)?.groups??{};if(l&&s[l]&&Array.isArray(s[l])){let h=s[l],p=[],v=!0,I=y=>{let w=y.trim();if(!w)return null;let f=w.endsWith(";")?w.slice(0,-1).trim():w,T=f.indexOf(":");if(T<=0||T>=f.length-1)return null;let m=f.slice(0,T).trim(),$=f.slice(T+1).trim();return!m||!$||!/^(?:--[a-zA-Z0-9-_]+|-?[a-zA-Z][a-zA-Z0-9-]*)$/.test(m)?null:`${m}:${$}`};for(let y of h){if(typeof y!="string"){v=!1;break}let w=I(y);if(w){if(typeof CSS<"u"&&!CSS.supports(w)){v=!1;break}p.push(w);continue}v=!1;break}if(p.length>0&&v)return p.join(";")}return null}function Pe(r,i){let l=Xe(r+i);if(l)return l;if(!r||i===void 0)return null;let h=U[r],p=h||r,v=i[0],I=!1,y=i;if(v==="!"&&(I=!0,y=y.substring(1),v=y[0]),y.startsWith("--"))y="var("+y+")";else if(v==="["&&y.endsWith("]"))y=y.substring(1,y.length-1);else if(y.length>0){let m=y[0].toLowerCase()+y.substring(1),$=ne[r]?.[m]||ye[m];if(!$){let M=y.toLowerCase();$=ne[r]?.[M]||ye[M]}y=$||y}if(y=y.replace(/(';|;)/g,m=>m=="';"?";":" "),!y)return null;let w=y+(I?" !important":""),f=[p+":"+w];switch(p){case"mx":f=[`margin-left:${w}`,`margin-right:${w}`];break;case"my":f=[`margin-top:${w}`,`margin-bottom:${w}`];break;case"px":f=[`padding-left:${w}`,`padding-right:${w}`];break;case"py":f=[`padding-top:${w}`,`padding-bottom:${w}`];break;case"bdx":f=[`border-left:${w}`,`border-right:${w}`];break;case"bdy":f=[`border-top:${w}`,`border-bottom:${w}`];break}return!(typeof CSS<"u")||f.every(m=>CSS.supports(m))?f.join(";"):null}let et=r=>{let i=0;for(let l=r.length-1;l>=0;l--){let h=r[l];if(h==="]"){i++;continue}if(h==="["){i>0&&i--;continue}if(h==="@"&&i===0)return{body:r.slice(0,l),selector:r.slice(l+1)}}return{body:r,selector:""}},tt=r=>{let i=[],l=0,h=0;for(let p=0;p<r.length;p++){let v=r[p];if(v==="["){h++;continue}if(v==="]"){h>0&&h--;continue}v==="&"&&h===0&&(i.push(r.slice(l,p)),l=p+1)}return i.push(r.slice(l)),i},ge=r=>{if(!r)return!0;let i=r.trim();if(!i)return!0;if(/[{}]/.test(i)||i==="#"||i==="("||i===")"||i===","||i===">"||i==="+"||i==="~"||i.startsWith("(")||i.startsWith(")"))return!1;let l=0;for(let h=0;h<i.length;h++){let p=i[h];if(p==="("){l++;continue}if(p===")"){if(l===0)return!1;l--}}return l===0};function $e(r){if(!ke(r))return null;let i=_?r.slice(_.length):r,l=typeof CSS<"u"?CSS.escape(r):rt(r);if(i.includes("&")&&!i.startsWith("&")){let{body:M,selector:Q}=et(i),Z=tt(M).map(A=>A.trim()).filter(A=>A.length>0).map(A=>_&&A.startsWith(_)?A.slice(_.length):A);if(Z.length>1){let A="",K="",k=Q,J=!1,H=[];for(let V of Z){let ie=k?`${V}@${k}`:V,D=ce(ie);if(!D||!de(D.mq)||!D.prop.startsWith("[")&&!fe(D.prop))return null;J?(!D.mq&&A&&(D.mq=A),!D.layer&&K&&(D.layer=K)):(A=D.mq||"",K=D.layer||"",J=!0);let ae=D.mq||"",he=D.layer||"",me=D.selector||"";if(ae!==A||he!==K||me!==k)return null;let ee=Pe(D.prop,D.val);if(!ee)return null;H.push(ee)}if(H.length===0)return null;let L=k.replace(/(';|;)/g,V=>V=="';"?";":" "),oe=`selector(${l}${L})`;if(L){if(typeof CSS<"u"){if(!CSS.supports(oe))return null}else if(!ge(L))return null}return{media:A||"default",layer:K||"0",className:l,property:H.join(";"),selector:L,cssRules:`.${l}${L}{${H.join(";")}}`}}}let h=ce(i);if(!h||!de(h.mq)||!h.prop.startsWith("[")&&!fe(h.prop))return null;let{mq:p="default",layer:v="0",prop:I,val:y,selector:w=""}=h,f=[],T=Pe(I,y);if(T&&f.push(T),f.length===0)return null;let m=w.replace(/(';|;)/g,M=>M=="';"?";":" "),$=`selector(${l}${m})`;if(m){if(typeof CSS<"u"){if(!CSS.supports($))return null}else if(!ge(m))return null}return{media:p||"default",layer:v||"0",className:l,property:f.join(";"),selector:m,cssRules:`.${l}${m}{${f.join(";")}}`}}let rt=r=>r.replace(/([^\w-])/g,"\\$1"),Se=r=>{var i=[...r?.classList||[]].filter(l=>{if(l){let h=l.charCodeAt(0)==45?l.charCodeAt(1):l.charCodeAt(0);return h>=97&&h<=122||h>=48&&h<=57}return!1});return r?.children?.length>0&&Array.from(r?.children).forEach(l=>{i.push(...Se(l))}),i.flat(1/0)},nt=(r,i)=>{if(typeof i!="function")throw new Error("Callback is not a function");if(!r)return;let l;"documentElement"in r?l=r.documentElement:(r instanceof Element||"tagName"in r||"host"in r)&&(l=r),l&&(l instanceof Element&&i(Se(l)),typeof MutationObserver<"u"&&new MutationObserver(h=>{for(let p of h)if(p.type=="attributes"&&p.attributeName=="class"){if(p.target.nodeType==1){let v=String(p.target?.className??""),I=String(p?.oldValue??"");if(v||I){let y=v.split(" ").map(f=>f.trim()).filter(f=>f),w=I.split(" ").map(f=>f.trim()).filter(f=>f);y=y.filter(f=>!w.includes(f)),typeof i=="function"&&i([...new Set(y)])}}}else if(p.type=="childList"&&p.addedNodes.length>0){let v=[...p.addedNodes].filter(I=>I.nodeType==1).map(I=>Se(I)).flat(1/0);typeof i=="function"&&i([...new Set(v)])}}).observe(l,{attributes:!0,attributeOldValue:!0,attributeFilter:["class"],childList:!0,subtree:!0}))};return{buildCss:Qe,exportCache:()=>{if(typeof window>"u"||!window.localStorage)return G;let r=xe(window.localStorage.getItem(R));if(r)return r;if(R!==N){let i=xe(window.localStorage.getItem(N));if(i)return i}return G},ready:se}},wt=(e,t)=>{Re(t).buildCss(e).observe()},xt=(e,t)=>Re(t).buildCss(e).clsx,Te={css:Re,cssObserve:wt,clsx:xt};var vt="xcss_cache_v1",Et=(e,t)=>{let n=String(t||"").trim();return n?n===vt||n.includes("_cache_")?n:`${e}_cache_${n}`:`${e}_cache_v1`},Rt=(e="fwkui",t="v1",n)=>{let s=String(e||"").trim()||"fwkui",o=Et(s,t),d=JSON.stringify(s),C=JSON.stringify(o),g=`
|
|
12
|
+
(async function () {
|
|
13
|
+
function decompressLZW(compressed) {
|
|
14
|
+
if (!compressed) return '';
|
|
15
|
+
var dictionary = {};
|
|
16
|
+
var dictSize = 256;
|
|
17
|
+
var i;
|
|
18
|
+
for (i = 0; i < 256; i++) dictionary[i] = String.fromCharCode(i);
|
|
19
|
+
var codes = compressed.split('').map(function (ch) { return ch.charCodeAt(0); });
|
|
20
|
+
var previous = codes[0];
|
|
21
|
+
var phrase = dictionary[previous] || '';
|
|
22
|
+
var result = phrase;
|
|
23
|
+
for (i = 1; i < codes.length; i++) {
|
|
24
|
+
var current = codes[i];
|
|
25
|
+
var entry = dictionary[current];
|
|
26
|
+
if (!entry) entry = current === dictSize ? phrase + phrase[0] : '';
|
|
27
|
+
result += entry;
|
|
28
|
+
dictionary[dictSize++] = phrase + entry[0];
|
|
29
|
+
phrase = entry;
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function canUseStream() {
|
|
35
|
+
return (
|
|
36
|
+
typeof DecompressionStream !== 'undefined' &&
|
|
37
|
+
typeof Blob !== 'undefined' &&
|
|
38
|
+
typeof Response !== 'undefined'
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function base64ToBytes(base64) {
|
|
43
|
+
if (typeof atob === 'function') {
|
|
44
|
+
var binary = atob(base64);
|
|
45
|
+
var bytes = new Uint8Array(binary.length);
|
|
46
|
+
for (var i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
47
|
+
return bytes;
|
|
48
|
+
}
|
|
49
|
+
if (typeof Buffer !== 'undefined') {
|
|
50
|
+
return new Uint8Array(Buffer.from(base64, 'base64'));
|
|
51
|
+
}
|
|
52
|
+
throw new Error('No base64 decoder');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function decompressDeflateRawBase64(payload) {
|
|
56
|
+
if (!canUseStream()) return null;
|
|
57
|
+
try {
|
|
58
|
+
var bytes = base64ToBytes(payload);
|
|
59
|
+
var stream = new Blob([bytes]).stream().pipeThrough(new DecompressionStream('deflate-raw'));
|
|
60
|
+
return await new Response(stream).text();
|
|
61
|
+
} catch (_error) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function parseCache(raw) {
|
|
67
|
+
if (!raw) return null;
|
|
68
|
+
try {
|
|
69
|
+
var parsed = JSON.parse(raw);
|
|
70
|
+
if (
|
|
71
|
+
parsed &&
|
|
72
|
+
parsed.__xcss_cache_v === 3 &&
|
|
73
|
+
parsed.compressed === true &&
|
|
74
|
+
parsed.algorithm === 'deflate-raw' &&
|
|
75
|
+
parsed.encoding === 'base64' &&
|
|
76
|
+
typeof parsed.payload === 'string'
|
|
77
|
+
) {
|
|
78
|
+
var expandedStream = await decompressDeflateRawBase64(parsed.payload);
|
|
79
|
+
if (!expandedStream) return null;
|
|
80
|
+
parsed = JSON.parse(expandedStream);
|
|
81
|
+
} else if (parsed && parsed.__xcss_cache_v === 2 && parsed.compressed === true && typeof parsed.payload === 'string') {
|
|
82
|
+
var expanded = decompressLZW(parsed.payload);
|
|
83
|
+
if (!expanded) return null;
|
|
84
|
+
parsed = JSON.parse(expanded);
|
|
85
|
+
}
|
|
86
|
+
if (!parsed || !parsed.cssText) return null;
|
|
87
|
+
return parsed;
|
|
88
|
+
} catch (_error) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
if (typeof window === 'undefined' || !window.localStorage) return;
|
|
95
|
+
|
|
96
|
+
var styleId = ${d};
|
|
97
|
+
var primaryKey = ${C};
|
|
98
|
+
var keys = primaryKey === 'xcss_cache_v1' ? [primaryKey] : [primaryKey, 'xcss_cache_v1'];
|
|
99
|
+
var payload = null;
|
|
100
|
+
|
|
101
|
+
for (var i = 0; i < keys.length; i++) {
|
|
102
|
+
var key = keys[i];
|
|
103
|
+
var raw = localStorage.getItem(key);
|
|
104
|
+
if (!raw) continue;
|
|
105
|
+
payload = await parseCache(raw);
|
|
106
|
+
if (!payload) {
|
|
107
|
+
localStorage.removeItem(key);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (payload) break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!payload) return;
|
|
114
|
+
|
|
115
|
+
var styleEl = document.getElementById(styleId);
|
|
116
|
+
if (!styleEl) {
|
|
117
|
+
styleEl = document.createElement('style');
|
|
118
|
+
styleEl.id = styleId;
|
|
119
|
+
document.head.appendChild(styleEl);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
var css = '';
|
|
123
|
+
if (payload.cssText.root) css += payload.cssText.root + '\\n';
|
|
124
|
+
for (var k in payload.cssText) {
|
|
125
|
+
if (k !== 'root') css += (payload.cssText[k] || '') + '\\n';
|
|
126
|
+
}
|
|
127
|
+
styleEl.textContent = css;
|
|
128
|
+
} catch (_error) {}
|
|
129
|
+
})();
|
|
130
|
+
`.trim();return n?.compact?g.replace(/\s+/g," ").trim():g};var _e="__FWXCSS_SHARED__",Tt={base:"html,body{font-size:16px;padding:0;margin:0;}"},_t=e=>{if(!e)return!1;let t=typeof Document<"u",n=typeof ShadowRoot<"u",s=t&&e instanceof Document,o=n&&e instanceof ShadowRoot;return s||o},It=e=>{let t=[],n=s=>{if(s){if(typeof s=="string"||typeof s=="number"){t.push(String(s));return}if(Array.isArray(s)){s.forEach(n);return}typeof s=="object"&&Object.keys(s).forEach(o=>{s[o]&&t.push(o)})}};return e.forEach(n),t},Ae=e=>{let t=new WeakMap,n=null,s=e??Tt,o=typeof document<"u"?document:null,d=x=>{let X=Te.css(s);return{...X.buildCss(x??void 0),ready:X.ready}},C=()=>(n||(n=d(null)),n),g=x=>{if(!x)return C();let X=t.get(x);return X||(X=d(x),t.set(x,X)),X};return{clsx:(...x)=>{let X,Y=x[x.length-1];_t(Y)&&(X=Y,x=x.slice(0,-1));let le=It(x);return g(X||o).clsx(le.join(" "))},observe:x=>{g(x||o).observe()},setClsxRoot:x=>{o=x||(typeof document<"u"?document:null)},getCss:x=>x?g(x).getCssString():o?g(o).getCssString():C().getCssString(),ready:x=>x?g(x).ready:o?g(o).ready:C().ready}},Ut=e=>Ae(e),Vt=e=>Ae(e),Ie=typeof globalThis<"u"?globalThis:typeof window<"u"?window:global,z=Ie[_e]||Ae();Ie[_e]||(Ie[_e]=z);var Nt=z.clsx,qt=z.observe,Ft=z.setClsxRoot,Zt=z.getCss,Jt=z.ready;var zt=Te;export{Nt as clsx,Vt as createSharedClsx,Ut as createSharedInstance,zt as default,Rt as getBootloaderScript,Zt as getCss,qt as observe,Jt as ready,Ft as setClsxRoot};
|
|
12
131
|
//# sourceMappingURL=index.mjs.map
|