@unocss/inspector 0.58.6 → 0.58.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- import{d as x,r as S,u as b,a as k,b as V,f as B,o as h,c as w,e as s,g as a,w as m,h as C,i as p,v as R,j as e,k as P,n as f,_ as E,l as N,m as U,p as $,q as I}from"./index-KQHM00Vf.js";const L={"h-full":"",grid:"~ rows-[max-content_1fr]","of-hidden":""},M=s("div",null," REPL Playground ",-1),T=s("div",{op60:""}," Edit your code below to test and play UnoCSS's matching and generating. ",-1),j={"h-full":"","of-hidden":"",grid:"","grid-cols-2":""},q=x({__name:"ReplPlayground",setup(y){const r=S(null),l=b(r,"repl-scrolls"),t=k("unocss:inspector:repl",`<div class="text-sm hover:text-red">
1
+ import{d as x,r as S,u as b,a as k,b as V,f as B,o as h,c as w,e as s,g as a,w as m,h as C,i as p,v as R,j as e,k as P,n as f,_ as E,l as N,m as U,p as $,q as I}from"./index-BcuhQbGA.js";const L={"h-full":"",grid:"~ rows-[max-content_1fr]","of-hidden":""},M=s("div",null," REPL Playground ",-1),T=s("div",{op60:""}," Edit your code below to test and play UnoCSS's matching and generating. ",-1),j={"h-full":"","of-hidden":"",grid:"","grid-cols-2":""},q=x({__name:"ReplPlayground",setup(y){const r=S(null),l=b(r,"repl-scrolls"),t=k("unocss:inspector:repl",`<div class="text-sm hover:text-red">
2
2
  Hello World
3
3
  </div>`),o=V("unocss-inspector-safelist",!1),{data:d}=B(t,o);return(H,n)=>{var i,_;const v=E,g=N,u=U;return h(),w("div",L,[s("div",{ref_key:"status",ref:r},[a(v,null,{default:m(()=>[M,T]),_:1}),a(g,{border:"b gray-400/20",title:""},{default:m(()=>[s("label",null,[C(s("input",{"onUpdate:modelValue":n[0]||(n[0]=c=>p(o)?o.value=c:null),type:"checkbox"},null,512),[[R,e(o)]]),P(" Include safelist ")])]),_:1})],512),s("div",j,[a(u,{modelValue:e(t),"onUpdate:modelValue":n[1]||(n[1]=c=>p(t)?t.value=c:null),mode:"html",matched:((i=e(d))==null?void 0:i.matched)||[],class:"scrolls repl-scrolls",style:f(e(l))},null,8,["modelValue","matched","style"]),a(u,{border:"l main","model-value":((_=e(d))==null?void 0:_.css)||"/* empty */","read-only":!0,mode:"css",class:"scrolls repl-scrolls",style:f(e(l))},null,8,["model-value","style"])])])}}}),z={};function D(y,r){const l=q;return h(),I(l)}const A=$(z,[["render",D]]);export{A 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-KQHM00Vf.js"></script>
11
+ <script type="module" crossorigin src="/__unocss/assets/index-BcuhQbGA.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/__unocss/assets/index-fgns7BIt.css">
13
13
  </head>
14
14
  <body>
package/dist/index.cjs CHANGED
@@ -57,7 +57,7 @@ const globalKeywords = [
57
57
  const numberWithUnitRE = /^(-?\d*(?:\.\d+)?)(px|pt|pc|%|r?(?:em|ex|lh|cap|ch|ic)|(?:[sld]?v|cq)(?:[whib]|min|max)|in|cm|mm|rpx)?$/i;
58
58
  const numberRE = /^(-?\d*(?:\.\d+)?)$/i;
59
59
  const unitOnlyRE = /^(px)$/i;
60
- const bracketTypeRe = /^\[(color|length|position|quoted|string):/i;
60
+ const bracketTypeRe = /^\[(color|length|size|position|quoted|string):/i;
61
61
 
62
62
  const cssProps = [
63
63
  // basic props
@@ -133,6 +133,8 @@ function auto(str) {
133
133
  return "auto";
134
134
  }
135
135
  function rem(str) {
136
+ if (!str)
137
+ return;
136
138
  if (unitOnlyRE.test(str))
137
139
  return `1${str}`;
138
140
  const match = str.match(numberWithUnitRE);
@@ -174,6 +176,8 @@ function percent(str) {
174
176
  return `${round(num / 100)}`;
175
177
  }
176
178
  function fraction(str) {
179
+ if (!str)
180
+ return;
177
181
  if (str === "full")
178
182
  return "100%";
179
183
  const [left, right] = str.split("/");
package/dist/index.mjs CHANGED
@@ -49,7 +49,7 @@ const globalKeywords = [
49
49
  const numberWithUnitRE = /^(-?\d*(?:\.\d+)?)(px|pt|pc|%|r?(?:em|ex|lh|cap|ch|ic)|(?:[sld]?v|cq)(?:[whib]|min|max)|in|cm|mm|rpx)?$/i;
50
50
  const numberRE = /^(-?\d*(?:\.\d+)?)$/i;
51
51
  const unitOnlyRE = /^(px)$/i;
52
- const bracketTypeRe = /^\[(color|length|position|quoted|string):/i;
52
+ const bracketTypeRe = /^\[(color|length|size|position|quoted|string):/i;
53
53
 
54
54
  const cssProps = [
55
55
  // basic props
@@ -125,6 +125,8 @@ function auto(str) {
125
125
  return "auto";
126
126
  }
127
127
  function rem(str) {
128
+ if (!str)
129
+ return;
128
130
  if (unitOnlyRE.test(str))
129
131
  return `1${str}`;
130
132
  const match = str.match(numberWithUnitRE);
@@ -166,6 +168,8 @@ function percent(str) {
166
168
  return `${round(num / 100)}`;
167
169
  }
168
170
  function fraction(str) {
171
+ if (!str)
172
+ return;
169
173
  if (str === "full")
170
174
  return "100%";
171
175
  const [left, right] = str.split("/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/inspector",
3
- "version": "0.58.6",
3
+ "version": "0.58.8",
4
4
  "description": "The inspector UI for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "gzip-size": "^6.0.0",
38
38
  "sirv": "^2.0.4",
39
- "@unocss/core": "0.58.6",
40
- "@unocss/rule-utils": "0.58.6"
39
+ "@unocss/rule-utils": "0.58.8",
40
+ "@unocss/core": "0.58.8"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "unbuild",
@@ -1 +0,0 @@
1
- import{s as Z,t as z,d as W,x as q,y as G,r as R,u as H,z as K,A as J,B as L,j as s,c as P,g as A,w as k,q as j,C as M,_ as Q,D as X,o as S,e as m,k as w,E as C,i as B,F,n as O,h as Y,v as ee,M as te,G as re,H as le,m as se,l as ae,I as ne}from"./index-KQHM00Vf.js";const D=/^(?!.*\[(?:[^:]+):(?:.+)\]$)((?:.+:)?!?)?(.*)$/;function ce(e={}){const h=e.prefix??"un-",r=e.prefixedOnly??!1,g=e.trueToNonValued??!1;let o;return{name:"attributify",match(a,{generator:$}){var _,c;const n=Z(a);if(!n)return;let t=n[1];if(t.startsWith(h))t=t.slice(h.length);else if(r)return;const i=n[2],[,x="",p=i]=i.match(D)||[];if(p==="~"||g&&p==="true"||!p)return`${x}${t}`;if(o==null){const l=(c=(_=$==null?void 0:$.config)==null?void 0:_.separators)==null?void 0:c.join("|");l?o=new RegExp(`^(.*\\](?:${l}))(\\[[^\\]]+?\\])$`):o=!1}if(o){const[,l,u]=i.match(o)||[];if(u)return`${l}${x}${t}-${u}`}return`${x}${t}-${p}`}}}const oe=/(<\w[\w:\.$-]*\s)((?:'[^>]*?'|"[^>]*?"|`[^>]*?`|\{[^>]*?\}|[^>]*?)*)/g,ie=/([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-]+)(?:=("[^"]*|'[^']*))?/g,I=/[\s'"`;>]+/;function ue(e){return{name:"attributify",extract:({content:h,cursor:r})=>{const g=h.matchAll(oe);let o,a=0;for(const f of g){const[,v,y]=f,b=f.index+v.length;if(r>b&&r<=b+y.length){a=b,o=y;break}}if(!o)return null;const $=o.matchAll(ie);let n=0,t,i;for(const f of $){const[v,y,b]=f,E=a+f.index;if(r>E&&r<=E+v.length){n=E,t=y,i=b==null?void 0:b.slice(1);break}}if(!t||t==="class"||t==="className"||t===":class")return null;const x=!!(e!=null&&e.prefix)&&t.startsWith(e.prefix);if(e!=null&&e.prefixedOnly&&!x)return null;const p=x?t.slice(e.prefix.length):t;if(i===void 0)return{extracted:p,resolveReplacement(f){const v=x?e.prefix.length:0;return{start:n+v,end:n+t.length,replacement:f}}};const _=n+t.length+2;let c=I.exec(i),l=0,u;for(;c;){const[f]=c;if(r>_+l&&r<=_+l+c.index){u=i.slice(l,l+c.index);break}l+=c.index+f.length,c=I.exec(i.slice(l))}u===void 0&&(u=i.slice(l));const[,d="",V]=u.match(D)||[];return{extracted:`${d}${p}-${V}`,transformSuggestions(f){return f.filter(v=>v.startsWith(`${d}${p}-`)).map(v=>d+v.slice(d.length+p.length+1))},resolveReplacement(f){return{start:l+_,end:l+_+u.length,replacement:d+f.slice(d.length+p.length+1)}}}}}}const de=["v-bind:",":"],T=/[\s'"`;]+/g,N=/<[^>\s]*\s((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/g,fe=/([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:!%-.~<]+)=?(?:["]([^"]*)["]|[']([^']*)[']|[{]([^}]*)[}])?/gms,U=["placeholder","fill","opacity","stroke-opacity"];function me(e){const h=(e==null?void 0:e.ignoreAttributes)??U,r=(e==null?void 0:e.nonValuedAttribute)??!0,g=(e==null?void 0:e.trueToNonValued)??!1;return{name:"@unocss/preset-attributify/extractor",extract({code:o}){return Array.from(o.matchAll(N)).flatMap(a=>Array.from((a[1]||"").matchAll(fe))).flatMap(([,a,...$])=>{const n=$.filter(Boolean).join("");if(h.includes(a))return[];for(const t of de)if(a.startsWith(t)){a=a.slice(t.length);break}if(!n){if(z(a)&&r!==!1){const t=[`[${a}=""]`];return g&&t.push(`[${a}="true"]`),t}return[]}return["class","className"].includes(a)?n.split(T).filter(z):N.test(n)?(N.lastIndex=0,this.extract({code:n})):e!=null&&e.prefixedOnly&&e.prefix&&!a.startsWith(e.prefix)?[]:n.split(T).filter(t=>!!t&&t!==":").map(t=>`[${a}~="${t}"]`)})}}}const he=(e={})=>{e.strict=e.strict??!1,e.prefix=e.prefix??"un-",e.prefixedOnly=e.prefixedOnly??!1,e.nonValuedAttribute=e.nonValuedAttribute??!0,e.ignoreAttributes=e.ignoreAttributes??U;const h=[ce(e)],r=[me(e)],g=[ue(e)];return{name:"@unocss/preset-attributify",enforce:"post",variants:h,extractors:r,options:e,autocomplete:{extractors:g},extractorDefault:e.strict?!1:void 0}},_e={key:0,"h-full":"","of-hidden":"",flex:"","flex-col":""},xe={p:"4",grid:"~ cols-4 gap-4"},pe=m("div",{op50:""}," Module ",-1),ye=m("div",{"i-carbon-launch":""},null,-1),ve=m("div",{op50:""}," Matched Rules ",-1),be=m("div",{op50:""}," CSS Size ",-1),ge=m("span",{op50:""},"gzipped",-1),$e={key:0,"row-span-3":""},Ae=m("div",{op50:""}," Potentially Unmatched ",-1),Ve={key:0,"h-full":"","of-hidden":""},ke=W({__name:"ModuleInfo",props:{id:{}},setup(e){const h=e,{data:r}=q(G(h,"id")),g=h.id.split(/\./g).pop(),o=R(null),a=H(o,"module-scrolls");function $(){fetch(`/__open-in-editor?file=${encodeURIComponent(h.id)}`)}const{extractors:n}=he({strict:!0}),t=K(async()=>{var c;const _=new Set;if(n){const l={code:((c=r.value)==null?void 0:c.code)||""};for(const u of n){const d=await u.extract(l);d==null||d.forEach(V=>_.add(V))}}return Array.from(_).filter(l=>!l.startsWith("[")).filter(l=>{var u,d;return!((d=(u=r.value)==null?void 0:u.matched)!=null&&d.some(({rawSelector:V})=>V===l))})}),i=R(!1),x=R("source"),p=J(L(()=>{var _;return(_=r.value)==null?void 0:_.css}),i);return(_,c)=>{const l=re,u=le,d=Q,V=se,f=ae,v=X;return s(r)?(S(),P("div",_e,[A(d,{ref_key:"status",ref:o,p0:""},{default:k(()=>{var y;return[m("div",xe,[m("div",null,[pe,m("a",{"cursor-pointer":"",op80:"","hover:op100":"",onClick:$},[A(l,{id:s(r).id,"mr-1":""},null,8,["id"]),ye])]),m("div",null,[ve,w(" "+C(s(r).matched.length),1)]),m("div",null,[be,w(" "+C(((((y=s(r))==null?void 0:y.gzipSize)||0)/1024).toFixed(2))+" KiB ",1),ge]),s(t).length?(S(),P("div",$e,[Ae,m("code",null,C(s(t).join(", ")),1)])):M("",!0)]),A(u,{modelValue:s(x),"onUpdate:modelValue":c[0]||(c[0]=b=>B(x)?x.value=b:null)},null,8,["modelValue"])]}),_:1},512),s(x)==="source"?(S(),P("div",Ve,[A(s(te),null,{default:k(()=>[A(s(F),{size:"50"},{default:k(()=>{var y;return[A(V,{"h-full":"","model-value":s(r).code,"read-only":!0,mode:s(g),matched:(y=s(r).matched)==null?void 0:y.map(({rawSelector:b})=>b),class:"scrolls module-scrolls",style:O(s(a))},null,8,["model-value","mode","matched","style"])]}),_:1}),A(s(F),{size:"50"},{default:k(()=>[m("div",null,[A(f,{border:"l b gray-400/20",title:"Output CSS"},{default:k(()=>[m("label",null,[Y(m("input",{"onUpdate:modelValue":c[1]||(c[1]=y=>B(i)?i.value=y:null),type:"checkbox"},null,512),[[ee,s(i)]]),w(" Prettify ")])]),_:1}),A(V,{"h-full":"",border:"l main","model-value":s(p),"read-only":!0,mode:"css",class:"scrolls module-scrolls",style:O(s(a))},null,8,["model-value","style"])])]),_:1})]),_:1})])):(S(),j(v,{key:1,"flex-grow":"","overflow-y-auto":"",selectors:s(r).matched,colors:s(r).colors},null,8,["selectors","colors"]))])):M("",!0)}}}),Ee=W({__name:"[id]",setup(e){const h=ne();return(r,g)=>{const o=ke;return S(),j(o,{id:s(h).params.id},null,8,["id"])}}});export{Ee as default};