@unocss/inspector 0.37.4 → 0.38.2

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 CHANGED
@@ -18,7 +18,7 @@ Visit `http://localhost:3000/__unocss` in your Vite dev server to see the inspec
18
18
  - [x] Auto reload on file changes (reuse Vite's hmr if possible)
19
19
  - [ ] Config view
20
20
  - [ ] Edit files directly
21
- - [ ] CSS Prettify
21
+ - [x] CSS Prettify
22
22
 
23
23
  > 🙌 Contribution welcome!
24
24
 
@@ -0,0 +1 @@
1
+ import{l as V,m as T,d as M,p as O,t as I,r as C,u as W,q as D,s as U,g as u,o as k,c as R,b as g,w as A,e as f,v as E,x as S,y as w,z as N,n as P,A as Z,B as j,C as q,D as K,_ as G,h as H,E as J,k as L,F as Q}from"./index.37306e5c.js";const X=t=>t.split(/[\s'"`;>=]+/g).filter(V),Y={name:"split",order:0,extract({code:t}){return new Set(X(t))}},B=/^(?!\[(?:[^:]+):(?:.+)\]$)((?:.+:)?!?)?(.*)$/,tt=(t={})=>{var i,h,d;const a=(i=t.prefix)!=null?i:"un-",c=(h=t.prefixedOnly)!=null?h:!1,_=(d=t.trueToNonValued)!=null?d:!1;return{name:"attributify",match(r){const o=T(r);if(!o)return;let e=o[1];if(e.startsWith(a))e=e.slice(a.length);else if(c)return;const p=o[2],[,l="",s=p]=p.match(B)||[];return s==="~"||_&&s==="true"||!s?`${l}${e}`:`${l}${e}-${s}`}}},et=/(<\w[\w:\.$-]*\s)((?:'[^>]*?'|"[^>]*?"|`[^>]*?`|\{[^>]*?\}|[^>]*?)*)/g,st=/([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-]+)(?:=("[^"]*|'[^']*))?/g,z=/[\s'"`;>]+/,rt={name:"attributify",extract:({content:t,cursor:a})=>{const c=t.matchAll(et);let _,i=0;for(const n of c){const[,x,y]=n,b=n.index+x.length;if(a>b&&a<=b+y.length){i=b,_=y;break}}if(!_)return null;const h=_.matchAll(st);let d=0,r,o;for(const n of h){const[x,y,b]=n,$=i+n.index;if(a>$&&a<=$+x.length){d=$,r=y,o=b==null?void 0:b.slice(1);break}}if(!r||r==="class"||r==="className")return null;if(o===void 0)return{extracted:r,resolveReplacement(n){return{start:d,end:d+r.length,replacement:n}}};const e=d+r.length+2;let p=z.exec(o),l=0,s;for(;p;){const[n]=p;if(a>e+l&&a<=e+l+p.index){s=o.slice(l,l+p.index);break}l+=p.index+n.length,p=z.exec(o.slice(l))}s===void 0&&(s=o.slice(l));const[,m="",v]=s.match(B)||[];return{extracted:`${m}${r}-${v}`,transformSuggestions(n){return n.filter(x=>x.startsWith(`${m}${r}-`)).map(x=>m+x.slice(m.length+r.length+1))},resolveReplacement(n){return{start:l+e,end:l+e+s.length,replacement:m+n.slice(m.length+r.length+1)}}}}},lt=["v-bind:",":"],F=/[\s'"`;]+/g,nt=/<\w(?=.*>)[\w:\.$-]*\s((?:['"`\{].*?['"`\}]|.*?)*?)>/gs,at=/([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:!%-]+)(?:=(["'])([^\2]*?)\2)?/g,ct=t=>{var i,h,d;const a=(i=t==null?void 0:t.ignoreAttributes)!=null?i:[],c=(h=t==null?void 0:t.nonValuedAttribute)!=null?h:!0,_=(d=t==null?void 0:t.trueToNonValued)!=null?d:!1;return{name:"attributify",extract({code:r}){const o=Array.from(r.matchAll(nt)).flatMap(e=>Array.from((e[1]||"").matchAll(at))).flatMap(([,e,p,l])=>{if(a.includes(e))return[];for(const s of lt)if(e.startsWith(s)){e=e.slice(s.length);break}if(!l){if(V(e)&&c!==!1){const s=[`[${e}=""]`];return _&&s.push(`[${e}="true"]`),s}return[]}return["class","className"].includes(e)?l.split(F).filter(V):l.split(F).filter(Boolean).map(s=>`[${e}~="${s}"]`)});return new Set(o)}}},ot=(t={})=>{var i,h,d,r,o;t.strict=(i=t.strict)!=null?i:!1,t.prefix=(h=t.prefix)!=null?h:"un-",t.prefixedOnly=(d=t.prefixedOnly)!=null?d:!1,t.nonValuedAttribute=(r=t.nonValuedAttribute)!=null?r:!0,t.ignoreAttributes=(o=t.ignoreAttributes)!=null?o:[];const a=[tt(t)],c=[ct(t)],_=[rt];return t.strict||c.unshift(Y),{name:"@unocss/preset-attributify",variants:a,extractors:c,options:t,autocomplete:{extractors:_}}},it={key:0,"h-full":"","of-hidden":""},ut=f("div",{op50:""}," Module ",-1),dt=f("div",{"i-carbon-launch":""},null,-1),ft=f("div",{op50:""}," Matched Rules ",-1),mt=f("div",{op50:""}," CSS Size ",-1),ht=f("span",{op50:""},"gzipped",-1),_t={key:0,"row-span-3":""},pt=f("div",{op50:""}," Potentially Unmatched ",-1),xt={"h-full":"","of-hidden":""},yt=E(" Prettify "),vt=M({name:"ModuleInfo",props:{id:null},setup(t){const a=t,{data:c}=O(I(a,"id")),_=a.id.split(/\./g).pop(),i=C(null),h=W(i,"module-scrolls");function d(){fetch(`/__open-in-editor?file=${encodeURIComponent(a.id)}`)}const{extractors:r}=ot({strict:!0}),o=D(async()=>{var s;const l=new Set;if(r){const m={code:((s=c.value)==null?void 0:s.code)||""};for(const v of r){const n=await v.extract(m);n==null||n.forEach(x=>l.add(x))}}return Array.from(l).filter(m=>!m.startsWith("[")).filter(m=>{var v;return!((v=c.value)!=null&&v.matched.includes(m))})}),e=C(!1),p=U(c,e);return(l,s)=>{const m=K,v=G,n=H,x=J;return u(c)?(k(),R("div",it,[g(v,{ref_key:"status",ref:i,grid:"~ cols-3 gap-4"},{default:A(()=>{var y;return[f("div",null,[ut,f("a",{"cursor-pointer":"",op80:"","hover:op100":"",onClick:d},[g(m,{id:u(c).id,"mr-1":""},null,8,["id"]),dt])]),f("div",null,[ft,E(" "+S(u(c).matched.length),1)]),f("div",null,[mt,E(" "+S(((((y=u(c))==null?void 0:y.gzipSize)||0)/1024).toFixed(2))+" KiB ",1),ht]),u(o).length?(k(),R("div",_t,[pt,f("code",null,S(u(o).join(", ")),1)])):w("",!0)]}),_:1},512),f("div",xt,[g(u(q),null,{default:A(()=>[g(u(N),{size:"50"},{default:A(()=>[g(n,{"h-full":"","model-value":u(c).code,"read-only":!0,mode:u(_),matched:u(c).matched,class:"scrolls module-scrolls",style:P(u(h))},null,8,["model-value","mode","matched","style"])]),_:1}),g(u(N),{size:"50"},{default:A(()=>[f("div",null,[g(x,{border:"l b gray-400/20",title:"Output CSS"},{default:A(()=>[f("label",null,[Z(f("input",{"onUpdate:modelValue":s[0]||(s[0]=y=>e.value=y),type:"checkbox"},null,512),[[j,e.value]]),yt])]),_:1}),g(n,{"h-full":"",b:"l main","model-value":u(p),"read-only":!0,mode:"css",class:"scrolls module-scrolls",style:P(u(h))},null,8,["model-value","style"])])]),_:1})]),_:1})])])):w("",!0)}}}),bt=M({name:"[id]",setup(t){const a=Q();return(c,_)=>{const i=vt;return k(),L(i,{id:u(a).params.id},null,8,["id"])}}});export{bt as default};