@unocss/inspector 0.14.2 → 0.14.3

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.
@@ -0,0 +1 @@
1
+ import{d as g,J as C,K as k,i as s,a as p,c as x,l as u,m as M,b as o,p as y,t as f,k as S,v as $,q as w}from"./vendor.6dcf7589.js";import{i as A,c as B,d as R,_ as V,a as z}from"./index.d3ee7df2.js";const E=["v-bind:",":"],b=/[\s'"`;]+/g,F=/<\w[\w:\.$-]*\s((?:'[\s\S]*?'|"[\s\S]*?"|`[\s\S]*?`|\{[\s\S]*?\}|[\s\S]*?)*?)>/g,N=/([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-]+)(?:=(["'])([^\2]+?)\2)?/g,j=d=>({name:"attributify",extract({code:n}){const e=Array.from(n.matchAll(F)).flatMap(t=>Array.from((t[1]||"").matchAll(N))).flatMap(([,t,l,a])=>{for(const r of E)if(t.startsWith(r)){t=t.slice(r.length);break}return a?["class","className"].includes(t)?a.split(b).filter(A):a.split(b).filter(Boolean).map(r=>`[${t}~="${r}"]`):A(t)&&(d==null?void 0:d.nonValuedAttribute)!==!1?[`[${t}=""]`]:[]});return new Set(e)}}),I={key:0,"h-full":"",grid:"~ rows-[max-content,1fr]","of-hidden":""},K=o("div",{op50:""}," Module ",-1),P=o("div",{"i-carbon-launch":""},null,-1),U=o("div",{op50:""}," Matched Rules ",-1),W=o("div",{op50:""}," CSS Size ",-1),q=o("span",{op50:""},"gzipped",-1),D={key:0,"row-span-3":""},J=o("div",{op50:""}," Potentially Unmatched ",-1),T={"h-full":"","of-hidden":"",grid:"","grid-cols-2":""},Z=g({props:{id:null},setup(d){const n=d,{data:e}=B(C(n,"id")),t=n.id.split(/\./g).pop();function l(){fetch(`/__open-in-editor?file=${encodeURIComponent(n.id)}`)}const a=j({strict:!0}),r=k(async()=>{var _;const m=await a.extract({code:((_=e.value)==null?void 0:_.code)||""})||[];return Array.from(m).filter(i=>!i.startsWith("[")).filter(i=>{var c;return!((c=e.value)==null?void 0:c.matched.includes(i))})});return(m,_)=>{const i=R,c=V,h=z;return s(e)?(p(),x("div",I,[u(c,{grid:"~ cols-3 gap-4"},{default:M(()=>{var v;return[o("div",null,[K,o("a",{"cursor-pointer":"",op80:"","hover:op100":"",onClick:l},[u(i,{id:s(e).id,"mr-1":""},null,8,["id"]),P])]),o("div",null,[U,y(" "+f(s(e).matched.length),1)]),o("div",null,[W,y(" "+f(((((v=s(e))==null?void 0:v.gzipSize)||0)/1024).toFixed(2))+" KiB ",1),q]),s(r).length?(p(),x("div",D,[J,o("code",null,f(s(r).join(", ")),1)])):S("",!0)]}),_:1}),o("div",T,[u(h,{"h-full":"","model-value":s(e).code,"read-only":!0,mode:s(t),matched:s(e).matched},null,8,["model-value","mode","matched"]),u(h,{"h-full":"",b:"l main","model-value":s(e).css,"read-only":!0,mode:"css"},null,8,["model-value"])])])):S("",!0)}}}),L=g({setup(d){const n=$();return(e,t)=>{const l=Z;return p(),w(l,{id:s(n).params.id},null,8,["id"])}}});export{L as default};
@@ -0,0 +1,3 @@
1
+ var ue=Object.defineProperty,pe=Object.defineProperties;var _e=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var J=(e,n,t)=>n in e?ue(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,F=(e,n)=>{for(var t in n||(n={}))he.call(n,t)&&J(e,t,n[t]);if(Z)for(var t of Z(n))me.call(n,t)&&J(e,t,n[t]);return e},Q=(e,n)=>pe(e,_e(n));import{C as fe,w as X,d as y,r as ve,u as ge,o as ye,n as xe,a as d,c as p,b as r,e as ke,f as Y,g as w,h as $,i as l,j as $e,F as O,t as _,k as E,l as h,m as x,p as g,q as b,s as V,v as be,x as R,y as ee,z as we,A as Ee,B as L,D as Re,E as Ce,G as je}from"./vendor.6dcf7589.js";const Se=function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerpolicy&&(i.referrerPolicy=s.referrerpolicy),s.crossorigin==="use-credentials"?i.credentials="include":s.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}};Se();const Fe="modulepreload",te={},Oe="/__unocss/",M=function(n,t){return!t||t.length===0?n():Promise.all(t.map(o=>{if(o=`${Oe}${o}`,o in te)return;te[o]=!0;const s=o.endsWith(".css"),i=s?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${i}`))return;const c=document.createElement("link");if(c.rel=s?"stylesheet":Fe,s||(c.as="script",c.crossOrigin=""),c.href=o,document.head.appendChild(c),s)return new Promise((a,m)=>{c.addEventListener("load",a),c.addEventListener("error",m)})})).then(()=>n())};function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Ve=/^\[(.+?)~?="(.*)"\]$/,Le=/(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;function Me(e){return e.match(Ve)}function Ut(e=""){return Le.test(e)}function Pe(e,n){const t=[],o=[],s=new Set;Array.from(n).forEach(c=>{const a=Me(c);a?a[2]?o.push(a):s.add(a[1]):s.add(c)});let i=0;return e.split(/[\s"';<>]/g).forEach(c=>{const a=i+c.length;s.has(c)&&t.push([i,a,c]),i=a+1}),o.forEach(([,c,a])=>{const m=new RegExp(`${oe(c)}=(['"])[^\\1]*?${oe(a)}[^\\1]*?\\1`,"g");Array.from(e.matchAll(m)).forEach(v=>{const f=v.index+v[0].indexOf(a),k=f+a.length;t.push([f,k,`[${c}="${a}"]`])})}),t}function Ie(e,n,t={}){const o=fe.fromTextArea(e.value,F({theme:"vars"},t));let s=!1;return o.on("change",()=>{if(s){s=!1;return}n.value=o.getValue()}),X(n,i=>{if(i!==o.getValue()){s=!0;const c=o.listSelections();o.replaceRange(i,o.posFromIndex(0),o.posFromIndex(1/0)),o.setSelections(c)}},{immediate:!0}),o}const Te={relative:"","font-mono":"","overflow-auto":"","text-sm":""},Ae=y({props:{modelValue:null,mode:null,readOnly:null,matched:null},setup(e,{emit:n}){const t=e,o={html:"htmlmixed",vue:"htmlmixed",js:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",mts:"typescript"},s=ve(),i=ge(t,"modelValue",n,{passive:!0});return ye(async()=>{const c=Ie(s,i,Q(F({},t),{mode:o[t.mode||""]||t.mode}));c.setSize("100%","100%"),setTimeout(()=>c.refresh(),100);const a=[];function m(f,k){a.push(c.markText(c.posFromIndex(f),c.posFromIndex(k),{className:"highlighted"}))}function v(){a.forEach(f=>f.clear()),Pe(t.modelValue,Array.from(t.matched||[])).forEach(f=>m(...f))}X(()=>[t.modelValue,t.matched],async()=>{await xe(),t.matched&&v()},{immediate:!0})}),(c,a)=>(d(),p("div",Te,[r("textarea",{ref:(m,v)=>{v.el=m,s.value=m}},null,512)]))}});var ne=(e,n)=>{for(const[t,o]of n)e[t]=o;return e};const De={},Ne={"bg-gray4:10":"","p-5":"",b:"b main",text:"sm gray5 dark:gray3"};function ze(e,n){return d(),p("div",Ne,[ke(e.$slots,"default")])}var Be=ne(De,[["render",ze]]);const Ue="/@vite/client",se=Y(),re=Y(),We=se.on,ce=re.on;M(()=>import(Ue),[]).then(e=>{const n=e.createHotContext("/");n.on("vite:beforeUpdate",t=>{t.updates.forEach(o=>{se.trigger(o)})}),n.on("unocss:config-changed",()=>{re.trigger()})}).catch(e=>{console.error("failed to connect to client vite server, you might need to do manual refresh to see the updates"),console.error(e)});const C="/__unocss_api",ie=w(C).json(),P=w(`${C}/overview`,{immediate:!1}).json(),u=ie.data,j=P.data;ce(()=>{ie.execute(),P.execute()});function Wt(e){const n=w($(()=>`${C}/module?id=${encodeURIComponent(l(e))}`),{refetch:!0}).json();return ce(()=>n.execute()),We(t=>{var o;(t.path===l(e)||t.path===l(e).slice(((o=u.value)==null?void 0:o.root.length)||0))&&setTimeout(()=>{n.execute()},50)}),n}function Ht(e){const n=$e(e,500);return w($(()=>`${C}/repl?token=${encodeURIComponent(n.value)}`),{refetch:!0}).json()}const S=$(()=>{if(!u.value)return{workspace:{children:{},items:[]},root:{children:{},items:[]}};const e=u.value.modules.map(o=>({full:o,path:o})),n=e.filter(o=>o.full.startsWith(u.value.root)),t=e.filter(o=>!o.full.startsWith(u.value.root));return n.forEach(o=>o.path=o.path.slice(u.value.root.length+1)),{workspace:ae(n,"Project Root"),root:ae(t,"Disk Root")}});function ae(e,n){const t={name:n,children:{},items:[]};function o(s,i,c=t){if(i.length<=1){c.items.push(s);return}const a=i.shift();c.children[a]||(c.children[a]={name:a,children:{},items:[]}),o(s,i,c.children[a])}return e.forEach(s=>{const i=s.path.split(/\//g).filter(Boolean);o(s,i)}),t}const He={key:0,"ws-wrap":""},qe=r("span",{op80:""},".",-1),Ke={key:1},Ge=y({props:{id:null},setup(e){return(n,t)=>e.id&&l(u)?(d(),p("span",He,[e.id.startsWith(l(u).root)?(d(),p(O,{key:0},[qe,r("span",null,_(e.id.slice(l(u).root.length)),1)],64)):(d(),p("span",Ke,_(e.id),1))])):E("",!0)}}),Ze={"h-full":"",grid:"~ rows-[max-content,1fr]"},Je={p4:"",grid:"~ cols-4 gap-4"},Qe=r("div",{op80:""}," Presets ",-1),Xe={op50:"","ws-pre":""},Ye={overflow:"auto"},et=r("div",{op80:""}," Rules ",-1),tt=r("span",{op50:""},"dynamic",-1),ot=r("br",null,null,-1),nt=r("span",{op50:""},"static",-1),st=r("div",{op80:""}," Variants ",-1),rt=r("div",{op80:""}," Shortcuts ",-1),ct={key:0},it=r("div",{op80:""}," Config File ",-1),at=r("div",{op80:""}," Version ",-1),lt={op50:"","ws-pre":""},dt={b:"t main",p4:"",grid:"~ cols-4 gap-4"},ut=r("div",{op80:""}," Included Files ",-1),pt=r("div",{op80:""}," CSS Size ",-1),_t=r("span",{op50:""},"gzipped",-1),ht=r("div",{op80:""}," Matched Rules ",-1),mt=r("div",{op80:""}," Layers ",-1),ft={op50:"","ws-pre":""},vt=y({setup(e){return P.execute(),(n,t)=>{var c;const o=Ge,s=Be,i=Ae;return d(),p("div",Ze,[h(s,{p0:""},{default:x(()=>{var a,m,v,f,k,I,T,A,D,N,z,B,U,W,H,q,K,G;return[r("div",Je,[r("div",null,[Qe,r("div",Xe,_((v=(m=(a=l(u))==null?void 0:a.config)==null?void 0:m.presets)==null?void 0:v.map(de=>de.name).join(`
2
+ `)),1)]),r("div",Ye,[et,g(" "+_((I=(k=(f=l(u))==null?void 0:f.config)==null?void 0:k.rulesDynamic)==null?void 0:I.length)+" ",1),tt,ot,g(" "+_(Object.keys(((A=(T=l(u))==null?void 0:T.config)==null?void 0:A.rulesStaticMap)||{}).length)+" ",1),nt]),r("div",null,[st,g(" "+_((z=(N=(D=l(u))==null?void 0:D.config)==null?void 0:N.variants)==null?void 0:z.length),1)]),r("div",null,[rt,g(" "+_((B=l(u))==null?void 0:B.config.shortcuts.length),1)]),((U=l(u))==null?void 0:U.configPath)?(d(),p("div",ct,[it,h(o,{id:l(u).configPath},null,8,["id"])])):E("",!0),r("div",null,[at,r("div",lt,_((W=l(u))==null?void 0:W.version),1)])]),r("div",dt,[r("div",null,[ut,g(" "+_((H=l(u))==null?void 0:H.modules.length),1)]),r("div",null,[pt,g(" "+_(((((q=l(j))==null?void 0:q.gzipSize)||0)/1024).toFixed(2))+" KiB ",1),_t]),r("div",null,[ht,g(" "+_((K=l(j))==null?void 0:K.matched.length),1)]),r("div",null,[mt,r("div",ft,_((G=l(j))==null?void 0:G.layers.join(`
3
+ `)),1)])])]}),_:1}),h(i,{"h-full":"","model-value":((c=l(j))==null?void 0:c.css)||"/* empty */","read-only":!0,mode:"css"},null,8,["model-value"])])}}}),gt={};function yt(e,n){const t=vt;return d(),b(t)}var xt=ne(gt,[["render",yt]]);const kt=[{name:"index",path:"/",component:xt,props:!0},{name:"repl",path:"/repl",component:()=>M(()=>import("./repl.b4923519.js"),["assets/repl.b4923519.js","assets/repl.bafd2276.css","assets/vendor.6dcf7589.js"]),props:!0},{name:"module-id",path:"/module/:id",component:()=>M(()=>import("./[id].55f4c95f.js"),["assets/[id].55f4c95f.js","assets/[id].e876e72e.css","assets/vendor.6dcf7589.js"]),props:!0}],$t=y({props:{id:null},setup(e){const n=e,t=$(()=>n.id.split(/\./g).pop()),o=$(()=>{switch(t.value){case"vue":return"i-logos-vue";default:return"i-carbon-document-blank"}});return(s,i)=>(d(),p("div",{class:V(l(o))},null,2))}}),bt={open:""},wt={"cursor-default":"","select-none":"","text-sm":"",truncate:"",p:"y1"},Et={"ml-1":""},Rt=y({props:{node:null,icon:{default:"i-carbon-folder"}},setup(e){const n=be();return(t,o)=>{const s=R("ModuleTreeNode",!0),i=$t,c=R("RouterLink");return d(),p("details",bt,[r("summary",wt,[r("div",{class:V(e.icon)},null,2),g(" "+_(e.node.name),1)]),(d(!0),p(O,null,ee(Object.entries(e.node.children),a=>(d(),b(s,{key:a[0],ml2:"",node:a[1]},null,8,["node"]))),128)),(d(!0),p(O,null,ee(e.node.items,a=>(d(),p("div",{key:a.full,ml4:"",truncate:""},[h(c,{block:"","text-sm":"",p:"x2 y1",rounded:"",to:`/module/${encodeURIComponent(a.full)}`,class:V({"bg-gray/10":a.full===l(n).params.id})},{default:x(()=>[h(i,{id:a.path},null,8,["id"]),r("span",Et,_(a.path.split("/").pop()),1)]),_:2},1032,["to","class"])]))),128))])}}});var Ct="/__unocss/icon.svg";const jt={p:"x4 y3",b:"b main",flex:"","children:my-auto":""},St=r("div",{flex:"","flex-auto":"","children:my-auto":"","ws-nowrap":""},[r("img",{src:Ct,filter:"","dark:invert":"","inline-block":"",h:"1.3em",m:"r-1.5"}),r("div",{"of-hidden":""},[g(" Inspector "),r("sup",{"text-teal5":"","bg-teal5:10":"",p:"x1.5 y0.5",rounded:"",italic:""},"beta")])],-1),Ft=y({setup(e){const n=we(),t=Ee(n);return(o,s)=>(d(),p("nav",jt,[St,r("button",{"text-lg":"","i-carbon-sun":"","dark:i-carbon-moon":"",onClick:s[0]||(s[0]=i=>l(t)())})]))}}),Ot={"h-full":"",grid:"~ rows-[max-content,1fr]",b:"r main","of-hidden":""},Vt={overflow:"auto",p:"y4",flex:"~ col gap-3"},Lt=r("div",{"i-carbon-dashboard":""},null,-1),Mt=r("span",null," Overview ",-1),Pt=r("div",{"i-carbon-terminal":""},null,-1),It=r("span",null," REPL ",-1),Tt=r("div",{b:"b main"},null,-1),At=y({setup(e){return(n,t)=>{const o=Ft,s=R("RouterLink"),i=Rt;return d(),p("div",Ot,[h(o),r("div",Vt,[h(s,{block:"",to:"/","text-sm":"",m:"l-3.7"},{default:x(()=>[Lt,Mt]),_:1}),h(s,{block:"",to:"/repl","text-sm":"",m:"l-3.7"},{default:x(()=>[Pt,It]),_:1}),Tt,Object.keys(l(S).workspace.children).length?(d(),b(i,{key:0,node:l(S).workspace,pl3:"",icon:"i-carbon-portfolio"},null,8,["node"])):E("",!0),Object.keys(l(S).root.children).length?(d(),b(i,{key:1,node:l(S).root,pl3:"",icon:"i-carbon-vmdk-disk"},null,8,["node"])):E("",!0)])])}}}),Dt={"h-full":"","of-hidden":""},Nt=y({setup(e){return(n,t)=>{const o=At,s=R("RouterView");return d(),b(l(L.exports.Splitpanes),{"h-full":"",flex:""},{default:x(()=>[h(l(L.exports.Pane),{size:"15","push-other-panes":!1},{default:x(()=>[h(o)]),_:1}),h(l(L.exports.Pane),{size:"85"},{default:x(()=>[r("div",Dt,[h(s)])]),_:1})]),_:1})}}}),le=Re(Nt);le.use(Ce({history:je(),routes:kt}));le.mount("#app");export{Be as _,Ae as a,ne as b,Wt as c,Ge as d,Ht as f,Ut as i};
@@ -1,3 +1,3 @@
1
- import{d as m,H as p,a as c,c as f,l as t,m as h,b as n,i as s,I as v,q as g}from"./vendor.6dcf7589.js";import{f as x,_ as y,a as b,b as B}from"./index.ed93a060.js";const V={"h-full":"",grid:"~ rows-[max-content,1fr]","of-hidden":""},C=n("div",null," REPL Playground ",-1),R=n("div",{op60:""}," Edit your code below to test and play UnoCSS's matching and generating. ",-1),S={"h-full":"","of-hidden":"",grid:"","grid-cols-2":""},k=m({setup(i){const e=p("unocss:inspector:repl",`<div class="text-sm hover:text-red">
1
+ import{d as m,H as f,a as c,c as p,l as t,m as h,b as n,i as s,I as v,q as g}from"./vendor.6dcf7589.js";import{f as x,_ as y,a as b,b as B}from"./index.d3ee7df2.js";const V={"h-full":"",grid:"~ rows-[max-content,1fr]","of-hidden":""},C=n("div",null," REPL Playground ",-1),R=n("div",{op60:""}," Edit your code below to test and play UnoCSS's matching and generating. ",-1),S={"h-full":"","of-hidden":"",grid:"","grid-cols-2":""},k=m({setup(i){const e=f("unocss:inspector:repl",`<div class="text-sm hover:text-red">
2
2
  Hello World
3
- </div>`),{data:o}=x(e);return(P,a)=>{var d,r;const u=y,l=b;return c(),f("div",V,[t(u,null,{default:h(()=>[C,R]),_:1}),n("div",S,[t(l,{modelValue:s(e),"onUpdate:modelValue":a[0]||(a[0]=_=>v(e)?e.value=_:null),"h-full":"",mode:"html",matched:((d=s(o))==null?void 0:d.matched)||[]},null,8,["modelValue","matched"]),t(l,{"h-full":"","b-l":"","b-main":"","model-value":((r=s(o))==null?void 0:r.css)||"/* empty */","read-only":!0,mode:"css"},null,8,["model-value"])])])}}}),w={};function E(i,e){const o=k;return c(),g(o)}var N=B(w,[["render",E]]);export{N as default};
3
+ </div>`),{data:o}=x(e);return(P,a)=>{var d,r;const u=y,l=b;return c(),p("div",V,[t(u,null,{default:h(()=>[C,R]),_:1}),n("div",S,[t(l,{modelValue:s(e),"onUpdate:modelValue":a[0]||(a[0]=_=>v(e)?e.value=_:null),"h-full":"",mode:"html",matched:((d=s(o))==null?void 0:d.matched)||[]},null,8,["modelValue","matched"]),t(l,{"h-full":"","b-l":"","b-main":"","model-value":((r=s(o))==null?void 0:r.css)||"/* empty */","read-only":!0,mode:"css"},null,8,["model-value"])])])}}}),w={};function E(i,e){const o=k;return c(),g(o)}var N=B(w,[["render",E]]);export{N as default};
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com" />
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
10
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;400&family=Fira+Code&display=swap" rel="stylesheet" />
11
- <script type="module" crossorigin src="/__unocss/assets/index.ed93a060.js"></script>
11
+ <script type="module" crossorigin src="/__unocss/assets/index.d3ee7df2.js"></script>
12
12
  <link rel="modulepreload" href="/__unocss/assets/vendor.6dcf7589.js">
13
13
  <link rel="stylesheet" href="/__unocss/assets/index.97c32687.css">
14
14
  </head>
package/dist/index.cjs ADDED
@@ -0,0 +1,98 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const url = require('url');
5
+ const sirv = require('sirv');
6
+ const gzipSize = require('gzip-size');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
9
+
10
+ const sirv__default = /*#__PURE__*/_interopDefaultLegacy(sirv);
11
+ const gzipSize__default = /*#__PURE__*/_interopDefaultLegacy(gzipSize);
12
+
13
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : path.dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))));
14
+ function UnocssInspector(ctx) {
15
+ let config;
16
+ async function configureServer(server) {
17
+ await ctx.ready;
18
+ server.middlewares.use("/__unocss", sirv__default(path.resolve(_dirname, "../dist/client"), {
19
+ single: true,
20
+ dev: true
21
+ }));
22
+ server.middlewares.use("/__unocss_api", async (req, res, next) => {
23
+ if (!req.url)
24
+ return next();
25
+ if (req.url === "/") {
26
+ const info = {
27
+ version: ctx.uno.version,
28
+ root: config.root,
29
+ modules: Array.from(ctx.modules.keys()),
30
+ config: ctx.uno.config,
31
+ configSources: (await ctx.ready).sources
32
+ };
33
+ res.setHeader("Content-Type", "application/json");
34
+ res.write(JSON.stringify(info, null, 2));
35
+ res.end();
36
+ return;
37
+ }
38
+ if (req.url.startsWith("/module")) {
39
+ const query = new URLSearchParams(req.url.slice(8));
40
+ const id = query.get("id") || "";
41
+ const code = ctx.modules.get(id);
42
+ if (code == null) {
43
+ res.statusCode = 404;
44
+ res.end();
45
+ return;
46
+ }
47
+ const result = await ctx.uno.generate(code, { id, preflights: false });
48
+ const mod = {
49
+ ...result,
50
+ matched: Array.from(result.matched),
51
+ gzipSize: await gzipSize__default(result.css),
52
+ code,
53
+ id
54
+ };
55
+ res.setHeader("Content-Type", "application/json");
56
+ res.write(JSON.stringify(mod, null, 2));
57
+ res.end();
58
+ return;
59
+ }
60
+ if (req.url.startsWith("/repl")) {
61
+ const query = new URLSearchParams(req.url.slice(5));
62
+ const token = query.get("token") || "";
63
+ const result = await ctx.uno.generate(token, { preflights: false });
64
+ const mod = {
65
+ ...result,
66
+ matched: Array.from(result.matched)
67
+ };
68
+ res.setHeader("Content-Type", "application/json");
69
+ res.write(JSON.stringify(mod, null, 2));
70
+ res.end();
71
+ return;
72
+ }
73
+ if (req.url.startsWith("/overview")) {
74
+ const result = await ctx.uno.generate(ctx.tokens);
75
+ const mod = {
76
+ ...result,
77
+ matched: Array.from(result.matched),
78
+ gzipSize: await gzipSize__default(result.css)
79
+ };
80
+ res.setHeader("Content-Type", "application/json");
81
+ res.write(JSON.stringify(mod, null, 2));
82
+ res.end();
83
+ return;
84
+ }
85
+ next();
86
+ });
87
+ }
88
+ return {
89
+ name: "unocss:inspector",
90
+ apply: "serve",
91
+ configResolved(_config) {
92
+ config = _config;
93
+ },
94
+ configureServer
95
+ };
96
+ }
97
+
98
+ module.exports = UnocssInspector;
package/dist/index.mjs CHANGED
@@ -1,29 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1
+ import { dirname, resolve } from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import sirv from 'sirv';
4
+ import gzipSize from 'gzip-size';
20
5
 
21
- // node/index.ts
22
- import { resolve, dirname } from "path";
23
- import { fileURLToPath } from "url";
24
- import sirv from "sirv";
25
- import gzipSize from "gzip-size";
26
- var _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
6
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
27
7
  function UnocssInspector(ctx) {
28
8
  let config;
29
9
  async function configureServer(server) {
@@ -58,12 +38,13 @@ function UnocssInspector(ctx) {
58
38
  return;
59
39
  }
60
40
  const result = await ctx.uno.generate(code, { id, preflights: false });
61
- const mod = __spreadProps(__spreadValues({}, result), {
41
+ const mod = {
42
+ ...result,
62
43
  matched: Array.from(result.matched),
63
44
  gzipSize: await gzipSize(result.css),
64
45
  code,
65
46
  id
66
- });
47
+ };
67
48
  res.setHeader("Content-Type", "application/json");
68
49
  res.write(JSON.stringify(mod, null, 2));
69
50
  res.end();
@@ -73,9 +54,10 @@ function UnocssInspector(ctx) {
73
54
  const query = new URLSearchParams(req.url.slice(5));
74
55
  const token = query.get("token") || "";
75
56
  const result = await ctx.uno.generate(token, { preflights: false });
76
- const mod = __spreadProps(__spreadValues({}, result), {
57
+ const mod = {
58
+ ...result,
77
59
  matched: Array.from(result.matched)
78
- });
60
+ };
79
61
  res.setHeader("Content-Type", "application/json");
80
62
  res.write(JSON.stringify(mod, null, 2));
81
63
  res.end();
@@ -83,10 +65,11 @@ function UnocssInspector(ctx) {
83
65
  }
84
66
  if (req.url.startsWith("/overview")) {
85
67
  const result = await ctx.uno.generate(ctx.tokens);
86
- const mod = __spreadProps(__spreadValues({}, result), {
68
+ const mod = {
69
+ ...result,
87
70
  matched: Array.from(result.matched),
88
71
  gzipSize: await gzipSize(result.css)
89
- });
72
+ };
90
73
  res.setHeader("Content-Type", "application/json");
91
74
  res.write(JSON.stringify(mod, null, 2));
92
75
  res.end();
@@ -104,6 +87,5 @@ function UnocssInspector(ctx) {
104
87
  configureServer
105
88
  };
106
89
  }
107
- export {
108
- UnocssInspector as default
109
- };
90
+
91
+ export { UnocssInspector as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/inspector",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "description": "The inspector UI for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -22,11 +22,11 @@
22
22
  "sideEffects": false,
23
23
  "exports": {
24
24
  ".": {
25
- "require": "./dist/index.js",
25
+ "require": "./dist/index.cjs",
26
26
  "import": "./dist/index.mjs"
27
27
  }
28
28
  },
29
- "main": "./dist/index.js",
29
+ "main": "./dist/index.cjs",
30
30
  "module": "./dist/index.mjs",
31
31
  "types": "./dist/index.d.ts",
32
32
  "files": [
@@ -37,9 +37,10 @@
37
37
  "sirv": "^1.0.18"
38
38
  },
39
39
  "scripts": {
40
- "build": "tsup",
40
+ "build": "unbuild",
41
41
  "build-post": "vite build",
42
- "dev": "tsup --watch node",
43
- "play": "vite"
42
+ "stub": "unbuild --stub",
43
+ "dev": "nr play",
44
+ "play": "nr stub && vite"
44
45
  }
45
46
  }
@@ -1 +0,0 @@
1
- import{d as g,J as k,K as w,i as s,a as p,c as x,l as u,m as A,b as o,p as y,t as f,k as S,v as M,q as $}from"./vendor.6dcf7589.js";import{i as b,c as B,d as R,_ as V,a as E}from"./index.ed93a060.js";const N=["v-bind:",":"],C=/[\s'"`;]+/g,z=/<\w[\w:\.$-]*\s((?:'[\s\S]*?'|"[\s\S]*?"|`[\s\S]*?`|\{[\s\S]*?\}|[\s\S]*?)*?)>/g,j=/([?]|[\w:%-]+)(?:=(["'])([^\2]+?)\2)?/g,I=a=>({name:"attributify",extract({code:n}){const e=Array.from(n.matchAll(z)).flatMap(t=>Array.from((t[1]||"").matchAll(j))).flatMap(([,t,c,i])=>{for(const r of N)if(t.startsWith(r)){t=t.slice(r.length);break}return i?["class","className"].includes(t)?i.split(C).filter(b):i.split(C).filter(Boolean).map(r=>`[${t}~="${r}"]`):b(t)&&(a==null?void 0:a.nonValuedAttribute)!==!1?[`[${t}=""]`]:[]});return new Set(e)}}),K={key:0,"h-full":"",grid:"~ rows-[max-content,1fr]","of-hidden":""},P=o("div",{op50:""}," Module ",-1),U=o("div",{"i-carbon-launch":""},null,-1),W=o("div",{op50:""}," Matched Rules ",-1),q=o("div",{op50:""}," CSS Size ",-1),D=o("span",{op50:""},"gzipped",-1),F={key:0,"row-span-3":""},J=o("div",{op50:""}," Potentially Unmatched ",-1),T={"h-full":"","of-hidden":"",grid:"","grid-cols-2":""},G=g({props:{id:null},setup(a){const n=a,{data:e}=B(k(n,"id")),t=n.id.split(/\./g).pop();function c(){fetch(`/__open-in-editor?file=${encodeURIComponent(n.id)}`)}const i=I({strict:!0}),r=w(async()=>{var _;const m=await i.extract({code:((_=e.value)==null?void 0:_.code)||""})||[];return Array.from(m).filter(l=>!l.startsWith("[")).filter(l=>{var d;return!((d=e.value)==null?void 0:d.matched.includes(l))})});return(m,_)=>{const l=R,d=V,h=E;return s(e)?(p(),x("div",K,[u(d,{grid:"~ cols-3 gap-4"},{default:A(()=>{var v;return[o("div",null,[P,o("a",{"cursor-pointer":"",op80:"","hover:op100":"",onClick:c},[u(l,{id:s(e).id,"mr-1":""},null,8,["id"]),U])]),o("div",null,[W,y(" "+f(s(e).matched.length),1)]),o("div",null,[q,y(" "+f(((((v=s(e))==null?void 0:v.gzipSize)||0)/1024).toFixed(2))+" KiB ",1),D]),s(r).length?(p(),x("div",F,[J,o("code",null,f(s(r).join(", ")),1)])):S("",!0)]}),_:1}),o("div",T,[u(h,{"h-full":"","model-value":s(e).code,"read-only":!0,mode:s(t),matched:s(e).matched},null,8,["model-value","mode","matched"]),u(h,{"h-full":"",b:"l main","model-value":s(e).css,"read-only":!0,mode:"css"},null,8,["model-value"])])])):S("",!0)}}}),O=g({setup(a){const n=M();return(e,t)=>{const c=G;return p(),$(c,{id:s(n).params.id},null,8,["id"])}}});export{O as default};
@@ -1,3 +0,0 @@
1
- var ue=Object.defineProperty,pe=Object.defineProperties;var _e=Object.getOwnPropertyDescriptors;var J=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var Q=(e,n,t)=>n in e?ue(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,O=(e,n)=>{for(var t in n||(n={}))he.call(n,t)&&Q(e,t,n[t]);if(J)for(var t of J(n))me.call(n,t)&&Q(e,t,n[t]);return e},X=(e,n)=>pe(e,_e(n));import{C as fe,w as Y,d as y,r as ve,u as ge,o as ye,n as xe,a as d,c as p,b as r,e as ke,f as Z,g as w,h as $,i as l,j as $e,F as V,t as _,k as E,l as h,m as x,p as g,q as b,s as L,v as be,x as R,y as ee,z as we,A as Ee,B as M,D as Re,E as Ce,G as je}from"./vendor.6dcf7589.js";const Se=function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerpolicy&&(i.referrerPolicy=s.referrerpolicy),s.crossorigin==="use-credentials"?i.credentials="include":s.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}};Se();const Oe="modulepreload",te={},Ve="/__unocss/",P=function(n,t){return!t||t.length===0?n():Promise.all(t.map(o=>{if(o=`${Ve}${o}`,o in te)return;te[o]=!0;const s=o.endsWith(".css"),i=s?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${i}`))return;const c=document.createElement("link");if(c.rel=s?"stylesheet":Oe,s||(c.as="script",c.crossOrigin=""),c.href=o,document.head.appendChild(c),s)return new Promise((a,m)=>{c.addEventListener("load",a),c.addEventListener("error",m)})})).then(()=>n())};function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Le=/^\[(.+?)~?="(.*)"\]$/,Me=/[a-z?]/;function Pe(e){return e.match(Le)}function Ut(e=""){return Me.test(e)}function Ie(e,n){const t=[],o=[],s=new Set;Array.from(n).forEach(c=>{const a=Pe(c);a?a[2]?o.push(a):s.add(a[1]):s.add(c)});let i=0;return e.split(/[\s"';<>]/g).forEach(c=>{const a=i+c.length;s.has(c)&&t.push([i,a,c]),i=a+1}),o.forEach(([,c,a])=>{const m=new RegExp(`${oe(c)}=(['"])[^\\1]*?${oe(a)}[^\\1]*?\\1`,"g");Array.from(e.matchAll(m)).forEach(v=>{const f=v.index+v[0].indexOf(a),k=f+a.length;t.push([f,k,`[${c}="${a}"]`])})}),t}function Te(e,n,t={}){const o=fe.fromTextArea(e.value,O({theme:"vars"},t));let s=!1;return o.on("change",()=>{if(s){s=!1;return}n.value=o.getValue()}),Y(n,i=>{if(i!==o.getValue()){s=!0;const c=o.listSelections();o.replaceRange(i,o.posFromIndex(0),o.posFromIndex(1/0)),o.setSelections(c)}},{immediate:!0}),o}const Fe={relative:"","font-mono":"","overflow-auto":"","text-sm":""},Ae=y({props:{modelValue:null,mode:null,readOnly:null,matched:null},setup(e,{emit:n}){const t=e,o={html:"htmlmixed",vue:"htmlmixed",js:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",mts:"typescript"},s=ve(),i=ge(t,"modelValue",n,{passive:!0});return ye(async()=>{const c=Te(s,i,X(O({},t),{mode:o[t.mode||""]||t.mode}));c.setSize("100%","100%"),setTimeout(()=>c.refresh(),100);const a=[];function m(f,k){a.push(c.markText(c.posFromIndex(f),c.posFromIndex(k),{className:"highlighted"}))}function v(){a.forEach(f=>f.clear()),Ie(t.modelValue,Array.from(t.matched||[])).forEach(f=>m(...f))}Y(()=>[t.modelValue,t.matched],async()=>{await xe(),t.matched&&v()},{immediate:!0})}),(c,a)=>(d(),p("div",Fe,[r("textarea",{ref:(m,v)=>{v.el=m,s.value=m}},null,512)]))}});var ne=(e,n)=>{for(const[t,o]of n)e[t]=o;return e};const De={},Ne={"bg-gray4:10":"","p-5":"",b:"b main",text:"sm gray5 dark:gray3"};function ze(e,n){return d(),p("div",Ne,[ke(e.$slots,"default")])}var Be=ne(De,[["render",ze]]);const Ue="/@vite/client",se=Z(),re=Z(),We=se.on,ce=re.on;P(()=>import(Ue),[]).then(e=>{const n=e.createHotContext("/");n.on("vite:beforeUpdate",t=>{t.updates.forEach(o=>{se.trigger(o)})}),n.on("unocss:config-changed",()=>{re.trigger()})}).catch(e=>{console.error("failed to connect to client vite server, you might need to do manual refresh to see the updates"),console.error(e)});const C="/__unocss_api",ie=w(C).json(),I=w(`${C}/overview`,{immediate:!1}).json(),u=ie.data,j=I.data;ce(()=>{ie.execute(),I.execute()});function Wt(e){const n=w($(()=>`${C}/module?id=${encodeURIComponent(l(e))}`),{refetch:!0}).json();return ce(()=>n.execute()),We(t=>{var o;(t.path===l(e)||t.path===l(e).slice(((o=u.value)==null?void 0:o.root.length)||0))&&setTimeout(()=>{n.execute()},50)}),n}function Ht(e){const n=$e(e,500);return w($(()=>`${C}/repl?token=${encodeURIComponent(n.value)}`),{refetch:!0}).json()}const S=$(()=>{if(!u.value)return{workspace:{children:{},items:[]},root:{children:{},items:[]}};const e=u.value.modules.map(o=>({full:o,path:o})),n=e.filter(o=>o.full.startsWith(u.value.root)),t=e.filter(o=>!o.full.startsWith(u.value.root));return n.forEach(o=>o.path=o.path.slice(u.value.root.length+1)),{workspace:ae(n,"Project Root"),root:ae(t,"Disk Root")}});function ae(e,n){const t={name:n,children:{},items:[]};function o(s,i,c=t){if(i.length<=1){c.items.push(s);return}const a=i.shift();c.children[a]||(c.children[a]={name:a,children:{},items:[]}),o(s,i,c.children[a])}return e.forEach(s=>{const i=s.path.split(/\//g).filter(Boolean);o(s,i)}),t}const He={key:0,"ws-wrap":""},qe=r("span",{op80:""},".",-1),Ke={key:1},Ge=y({props:{id:null},setup(e){return(n,t)=>e.id&&l(u)?(d(),p("span",He,[e.id.startsWith(l(u).root)?(d(),p(V,{key:0},[qe,r("span",null,_(e.id.slice(l(u).root.length)),1)],64)):(d(),p("span",Ke,_(e.id),1))])):E("",!0)}}),Je={"h-full":"",grid:"~ rows-[max-content,1fr]"},Qe={p4:"",grid:"~ cols-4 gap-4"},Xe=r("div",{op80:""}," Presets ",-1),Ye={op50:"","ws-pre":""},Ze={overflow:"auto"},et=r("div",{op80:""}," Rules ",-1),tt=r("span",{op50:""},"dynamic",-1),ot=r("br",null,null,-1),nt=r("span",{op50:""},"static",-1),st=r("div",{op80:""}," Variants ",-1),rt=r("div",{op80:""}," Shortcuts ",-1),ct={key:0},it=r("div",{op80:""}," Config File ",-1),at=r("div",{op80:""}," Version ",-1),lt={op50:"","ws-pre":""},dt={b:"t main",p4:"",grid:"~ cols-4 gap-4"},ut=r("div",{op80:""}," Included Files ",-1),pt=r("div",{op80:""}," CSS Size ",-1),_t=r("span",{op50:""},"gzipped",-1),ht=r("div",{op80:""}," Matched Rules ",-1),mt=r("div",{op80:""}," Layers ",-1),ft={op50:"","ws-pre":""},vt=y({setup(e){return I.execute(),(n,t)=>{var c;const o=Ge,s=Be,i=Ae;return d(),p("div",Je,[h(s,{p0:""},{default:x(()=>{var a,m,v,f,k,T,F,A,D,N,z,B,U,W,H,q,K,G;return[r("div",Qe,[r("div",null,[Xe,r("div",Ye,_((v=(m=(a=l(u))==null?void 0:a.config)==null?void 0:m.presets)==null?void 0:v.map(de=>de.name).join(`
2
- `)),1)]),r("div",Ze,[et,g(" "+_((T=(k=(f=l(u))==null?void 0:f.config)==null?void 0:k.rulesDynamic)==null?void 0:T.length)+" ",1),tt,ot,g(" "+_(Object.keys(((A=(F=l(u))==null?void 0:F.config)==null?void 0:A.rulesStaticMap)||{}).length)+" ",1),nt]),r("div",null,[st,g(" "+_((z=(N=(D=l(u))==null?void 0:D.config)==null?void 0:N.variants)==null?void 0:z.length),1)]),r("div",null,[rt,g(" "+_((B=l(u))==null?void 0:B.config.shortcuts.length),1)]),((U=l(u))==null?void 0:U.configPath)?(d(),p("div",ct,[it,h(o,{id:l(u).configPath},null,8,["id"])])):E("",!0),r("div",null,[at,r("div",lt,_((W=l(u))==null?void 0:W.version),1)])]),r("div",dt,[r("div",null,[ut,g(" "+_((H=l(u))==null?void 0:H.modules.length),1)]),r("div",null,[pt,g(" "+_(((((q=l(j))==null?void 0:q.gzipSize)||0)/1024).toFixed(2))+" KiB ",1),_t]),r("div",null,[ht,g(" "+_((K=l(j))==null?void 0:K.matched.length),1)]),r("div",null,[mt,r("div",ft,_((G=l(j))==null?void 0:G.layers.join(`
3
- `)),1)])])]}),_:1}),h(i,{"h-full":"","model-value":((c=l(j))==null?void 0:c.css)||"/* empty */","read-only":!0,mode:"css"},null,8,["model-value"])])}}}),gt={};function yt(e,n){const t=vt;return d(),b(t)}var xt=ne(gt,[["render",yt]]);const kt=[{name:"index",path:"/",component:xt,props:!0},{name:"repl",path:"/repl",component:()=>P(()=>import("./repl.0c68f84f.js"),["assets/repl.0c68f84f.js","assets/repl.bafd2276.css","assets/vendor.6dcf7589.js"]),props:!0},{name:"module-id",path:"/module/:id",component:()=>P(()=>import("./[id].751da2a7.js"),["assets/[id].751da2a7.js","assets/[id].e876e72e.css","assets/vendor.6dcf7589.js"]),props:!0}],$t=y({props:{id:null},setup(e){const n=e,t=$(()=>n.id.split(/\./g).pop()),o=$(()=>{switch(t.value){case"vue":return"i-logos-vue";default:return"i-carbon-document-blank"}});return(s,i)=>(d(),p("div",{class:L(l(o))},null,2))}}),bt={open:""},wt={"cursor-default":"","select-none":"","text-sm":"",truncate:"",p:"y1"},Et={"ml-1":""},Rt=y({props:{node:null,icon:{default:"i-carbon-folder"}},setup(e){const n=be();return(t,o)=>{const s=R("ModuleTreeNode",!0),i=$t,c=R("RouterLink");return d(),p("details",bt,[r("summary",wt,[r("div",{class:L(e.icon)},null,2),g(" "+_(e.node.name),1)]),(d(!0),p(V,null,ee(Object.entries(e.node.children),a=>(d(),b(s,{key:a[0],ml2:"",node:a[1]},null,8,["node"]))),128)),(d(!0),p(V,null,ee(e.node.items,a=>(d(),p("div",{key:a.full,ml4:"",truncate:""},[h(c,{block:"","text-sm":"",p:"x2 y1",rounded:"",to:`/module/${encodeURIComponent(a.full)}`,class:L({"bg-gray/10":a.full===l(n).params.id})},{default:x(()=>[h(i,{id:a.path},null,8,["id"]),r("span",Et,_(a.path.split("/").pop()),1)]),_:2},1032,["to","class"])]))),128))])}}});var Ct="/__unocss/icon.svg";const jt={p:"x4 y3",b:"b main",flex:"","children:my-auto":""},St=r("div",{flex:"","flex-auto":"","children:my-auto":"","ws-nowrap":""},[r("img",{src:Ct,filter:"","dark:invert":"","inline-block":"",h:"1.3em",m:"r-1.5"}),r("div",{"of-hidden":""},[g(" Inspector "),r("sup",{"text-teal5":"","bg-teal5:10":"",p:"x1.5 y0.5",rounded:"",italic:""},"beta")])],-1),Ot=y({setup(e){const n=we(),t=Ee(n);return(o,s)=>(d(),p("nav",jt,[St,r("button",{"text-lg":"","i-carbon-sun":"","dark:i-carbon-moon":"",onClick:s[0]||(s[0]=i=>l(t)())})]))}}),Vt={"h-full":"",grid:"~ rows-[max-content,1fr]",b:"r main","of-hidden":""},Lt={overflow:"auto",p:"y4",flex:"~ col gap-3"},Mt=r("div",{"i-carbon-dashboard":""},null,-1),Pt=r("span",null," Overview ",-1),It=r("div",{"i-carbon-terminal":""},null,-1),Tt=r("span",null," REPL ",-1),Ft=r("div",{b:"b main"},null,-1),At=y({setup(e){return(n,t)=>{const o=Ot,s=R("RouterLink"),i=Rt;return d(),p("div",Vt,[h(o),r("div",Lt,[h(s,{block:"",to:"/","text-sm":"",m:"l-3.7"},{default:x(()=>[Mt,Pt]),_:1}),h(s,{block:"",to:"/repl","text-sm":"",m:"l-3.7"},{default:x(()=>[It,Tt]),_:1}),Ft,Object.keys(l(S).workspace.children).length?(d(),b(i,{key:0,node:l(S).workspace,pl3:"",icon:"i-carbon-portfolio"},null,8,["node"])):E("",!0),Object.keys(l(S).root.children).length?(d(),b(i,{key:1,node:l(S).root,pl3:"",icon:"i-carbon-vmdk-disk"},null,8,["node"])):E("",!0)])])}}}),Dt={"h-full":"","of-hidden":""},Nt=y({setup(e){return(n,t)=>{const o=At,s=R("RouterView");return d(),b(l(M.exports.Splitpanes),{"h-full":"",flex:""},{default:x(()=>[h(l(M.exports.Pane),{size:"15","push-other-panes":!1},{default:x(()=>[h(o)]),_:1}),h(l(M.exports.Pane),{size:"85"},{default:x(()=>[r("div",Dt,[h(s)])]),_:1})]),_:1})}}}),le=Re(Nt);le.use(Ce({history:je(),routes:kt}));le.mount("#app");export{Be as _,Ae as a,ne as b,Wt as c,Ge as d,Ht as f,Ut as i};
package/dist/index.js DELETED
@@ -1,137 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
- var __export = (target, all) => {
26
- __markAsModule(target);
27
- for (var name in all)
28
- __defProp(target, name, { get: all[name], enumerable: true });
29
- };
30
- var __reExport = (target, module2, desc) => {
31
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
32
- for (let key of __getOwnPropNames(module2))
33
- if (!__hasOwnProp.call(target, key) && key !== "default")
34
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
35
- }
36
- return target;
37
- };
38
- var __toModule = (module2) => {
39
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
40
- };
41
-
42
- // node/index.ts
43
- __export(exports, {
44
- default: () => UnocssInspector
45
- });
46
-
47
- // ../../node_modules/.pnpm/tsup@5.5.0_typescript@4.5.2/node_modules/tsup/assets/cjs_shims.js
48
- var importMetaUrlShim = typeof document === "undefined" ? new (require("url")).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
49
-
50
- // node/index.ts
51
- var import_path = __toModule(require("path"));
52
- var import_url = __toModule(require("url"));
53
- var import_sirv = __toModule(require("sirv"));
54
- var import_gzip_size = __toModule(require("gzip-size"));
55
- var _dirname = typeof __dirname !== "undefined" ? __dirname : (0, import_path.dirname)((0, import_url.fileURLToPath)(importMetaUrlShim));
56
- function UnocssInspector(ctx) {
57
- let config;
58
- async function configureServer(server) {
59
- await ctx.ready;
60
- server.middlewares.use("/__unocss", (0, import_sirv.default)((0, import_path.resolve)(_dirname, "../dist/client"), {
61
- single: true,
62
- dev: true
63
- }));
64
- server.middlewares.use("/__unocss_api", async (req, res, next) => {
65
- if (!req.url)
66
- return next();
67
- if (req.url === "/") {
68
- const info = {
69
- version: ctx.uno.version,
70
- root: config.root,
71
- modules: Array.from(ctx.modules.keys()),
72
- config: ctx.uno.config,
73
- configSources: (await ctx.ready).sources
74
- };
75
- res.setHeader("Content-Type", "application/json");
76
- res.write(JSON.stringify(info, null, 2));
77
- res.end();
78
- return;
79
- }
80
- if (req.url.startsWith("/module")) {
81
- const query = new URLSearchParams(req.url.slice(8));
82
- const id = query.get("id") || "";
83
- const code = ctx.modules.get(id);
84
- if (code == null) {
85
- res.statusCode = 404;
86
- res.end();
87
- return;
88
- }
89
- const result = await ctx.uno.generate(code, { id, preflights: false });
90
- const mod = __spreadProps(__spreadValues({}, result), {
91
- matched: Array.from(result.matched),
92
- gzipSize: await (0, import_gzip_size.default)(result.css),
93
- code,
94
- id
95
- });
96
- res.setHeader("Content-Type", "application/json");
97
- res.write(JSON.stringify(mod, null, 2));
98
- res.end();
99
- return;
100
- }
101
- if (req.url.startsWith("/repl")) {
102
- const query = new URLSearchParams(req.url.slice(5));
103
- const token = query.get("token") || "";
104
- const result = await ctx.uno.generate(token, { preflights: false });
105
- const mod = __spreadProps(__spreadValues({}, result), {
106
- matched: Array.from(result.matched)
107
- });
108
- res.setHeader("Content-Type", "application/json");
109
- res.write(JSON.stringify(mod, null, 2));
110
- res.end();
111
- return;
112
- }
113
- if (req.url.startsWith("/overview")) {
114
- const result = await ctx.uno.generate(ctx.tokens);
115
- const mod = __spreadProps(__spreadValues({}, result), {
116
- matched: Array.from(result.matched),
117
- gzipSize: await (0, import_gzip_size.default)(result.css)
118
- });
119
- res.setHeader("Content-Type", "application/json");
120
- res.write(JSON.stringify(mod, null, 2));
121
- res.end();
122
- return;
123
- }
124
- next();
125
- });
126
- }
127
- return {
128
- name: "unocss:inspector",
129
- apply: "serve",
130
- configResolved(_config) {
131
- config = _config;
132
- },
133
- configureServer
134
- };
135
- }
136
- // Annotate the CommonJS export names for ESM import in node:
137
- 0 && (module.exports = {});