@limeui/unocss-preset 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -409,10 +409,10 @@ ${d.join(`
409
409
  `);return`${e.selector} {
410
410
  ${r}
411
411
  }`}function aa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Bn="",Nn="",pc="",ia=null,sa=new Set;function dc(e,t){let r=[];return e.outFile&&re&&process.env.NODE_ENV!=="production"&&(Nn=e.outFile,pc=t||process.env.VITE_ROOT_DIR||process.cwd(),Bn="",sa.clear()),r.push(n=>{if(e.replaceOpacityVar){let o=new Map,a=[];for(let i of n.entries){let[s,c]=i,l=String(s);l.startsWith("--un-")&&l.endsWith("-opacity")&&o.set(l,parseFloat(`${c}`)||1)}for(let i of n.entries){let[s,c]=i,l=String(s),u=String(c);if(l.startsWith("--")&&u.includes("!important")&&(u=u.replace("!important","")),typeof c=="string"){let d=u;for(let h of o.keys())d.startsWith("rgb")&&(d.startsWith("rgba")?d=d.replace(new RegExp(`var\\(${aa(h)}\\)`,"g"),()=>{let m=o.get(h);return m!==void 0?String(m):`var(${h})`}):d=d.replace(new RegExp(`rgb\\(\\s*(\\d+(?:\\.\\d+)?)\\s+(\\d+(?:\\.\\d+)?)\\s+(\\d+(?:\\.\\d+)?)\\s*\\/\\s*var\\(${aa(h)}\\)\\s*\\)`,"gi"),(m,g,b,k)=>{let w=o.get(h);return`rgba(${g}, ${b}, ${k}, ${w!==void 0?w:`var(${h})`})`}),d=d.replace(/\/\*\s*[^*]*\s*\*\//g,""));d=d.replace(/\s*\/\*.*?\*\/\s*$/,""),a.push([s,d])}else a.push([s,c])}n.entries=a}if(Nn){let o=uc(n,n.entries);o&&n.selector&&!sa.has(n.selector)&&(Bn+=o+`
412
- `,sa.add(n.selector),Sh())}}),r}async function Sh(){ia&&clearTimeout(ia),ia=setTimeout(async()=>{Nn&&Bn&&await $h(wh(pc,Nn),Bn,"utf-8").catch(e=>{console.error("Failed to write UnoCSS output file:",e)})},500)}var zh=["360","mp","app","appx","quickapp","app-plus","h5","web","mp-360","mp-alipay","mp-baidu","mp-jd","mp-kuaishou","mp-lark","mp-qq","mp-toutiao","mp-weixin","quickapp-webview","quickapp-webview-huawei","quickapp-webview-union"],mc={platforms:zh.reduce((e,t)=>{e[t]=t;let r=t.replace(/^mp-/,"");return r&&r!==t&&(e[r]=t),e},{mp:"mp",app:"app",quickapp:"quickapp",h5:"h5",web:"h5"})};function hc(){return[{name:"unocss-preset-unix-platforms",match(t,r){let n=Y("uni-",t,r.generator.config.separators);if(n){let[o,a]=n,i=p.bracket(o)??o,{platforms:s={}}=r.theme;if(i){let c=o.startsWith("not-"),l=c?o.slice(4):o;if(p.bracket(o)?l=p.bracket(o)??"":l===""&&(l=s[c?o.slice(4):o]??""),l){let u=process.env.UNI_PLATFORM,d=Eh(u,l);return(c?!d:d)?{matcher:a}:null}}}},multiPass:!0,autocomplete:"uni-$platforms:"}]}function Eh(e,t){if(!e)return!1;let r=Ch(t);for(let n of r)if(re&&n==="appx"||(n==="h5"||n==="web")&&(e==="h5"||e==="web")||e!==void 0&&e.startsWith(n))return!0;return!1}function Ch(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1).split(",").map(r=>r.trim()).filter(r=>r):[e]}var jh=/[\s'"`;]+/g;function _h(e=[]){if(!e.length)return/<\w(?=.*>)[\w:.$-]*\s(((".*?>?.*?")|.*?)*?)\/?>/gs;let t=e.flatMap(n=>{let o=n.toLowerCase(),a=o.charAt(0).toUpperCase()+o.slice(1),i=`${o}-`;return[a,i]}),r=t.length?`(?!${t.join("|")})`:"";return new RegExp(`<${r}\\w(?=.*>)[\\w:.$-]*\\s(((".*?>?.*?")|.*?)*?)\\/?>`,"gs")}var Ah=/([[?\w\u00A0-\uFFFF-:()#%.\]]+)(?:\s*=\s*('[^']*'|"[^"]*"|\S+))?/g,Rh=["placeholder","setup","lang","scoped"];function gc(e={}){let t=e?.ignoreAttributes??Rh,r=e?.nonValuedAttribute??!0,n=e.prefix??"un-",o=e.prefixedOnly??!1,a=e.deleteAttributes??!0,i=_h(e.ignoreTagPrefixes??[]);return{name:"transformer-attributify",enforce:"pre",async transform(s,c,{uno:l}){if(!/\.vue$/.test(c))return;let u=new Ke(s.toString()),d=u.original.matchAll(i);for(let h of d){let m=h.index,g=h[0],b="",k=[],w=Array.from((h[1]||"").matchAll(Ah));for(let x of w){let S=x[0],_=x[1];if(_.startsWith(":"))continue;let E=x[2],C=_.replace(n,"");if(!t.includes(C))if(E){if(_.includes("hover-class"))continue;if(["class","className"].includes(_))_.includes(":")||(b=E.replace(/['"`]/g,""));else{if(o&&n&&!_.startsWith(n))continue;let N=[];for(let H of E.split(jh).filter(Boolean)){let ye=H;if(H.includes(":")){let Z=H.split(":");ye=`${Z[0]}:${Z[1]}`,await l.parseToken(`${C}-${Z[1]}`)?N.push(`${Z[0]}:${C}-${Z[1]}`):await l.parseToken(`${Z[0]}:${Z[1]}`)&&N.push(`${Z[0]}:${Z[1]}`)}else H==="~"?ye=C:H.startsWith("!")?ye=`!${C}-${H.slice(1)}`:ye=`${C}-${H}`,await l.parseToken(ye)&&N.push(ye)}k.push(...N),N.length&&a&&(g=g.replace(` ${S}`,""))}}else{if(o&&n&&!_.startsWith(n))continue;Te(C)&&r&&await l.parseToken(C)&&(k.push(C),a&&(g=g.replace(` ${_}`,"")))}}if(k.length){if(b)g=g.replace(`"${b}"`,`"${b} ${k.join(" ")}"`);else{let x=g.endsWith("/>")?-2:-1;g=`${g.slice(0,x)} class="${k.join(" ")}"${g.slice(x)}`}u.overwrite(m,m+h[0].length,g)}}s.overwrite(0,s.original.length,u.toString())}}}var Ph=/(?<!<!--\s*)/,Oh=/<style([^>]*)>[\s\S]*?<\/style\s*>/,Mh=new RegExp(Ph.source+Oh.source,"g"),Fh=e=>({name:"unocss-inline-style",enforce:"pre",async transform(t,r,{uno:n,tokens:o}){if(!re||!oa)return;let a=r.split(".").pop();if(a!=="uvue"&&a!=="vue")return;let i=t.toString(),c=(await n.generate(i,{preflights:!0})).getLayers(e?.includeLayers??["theme","default"],e?.excludeLayers);if(!c)return;let l=i.match(Mh),u;l?u=i.replace(/(<\/style\s*>)/,`${c}
412
+ `,sa.add(n.selector),Sh())}}),r}async function Sh(){ia&&clearTimeout(ia),ia=setTimeout(async()=>{Nn&&Bn&&await $h(wh(pc,Nn),Bn,"utf-8").catch(e=>{console.error("Failed to write UnoCSS output file:",e)})},500)}var zh=["360","mp","app","appx","quickapp","app-plus","h5","web","mp-360","mp-alipay","mp-baidu","mp-jd","mp-kuaishou","mp-lark","mp-qq","mp-toutiao","mp-weixin","quickapp-webview","quickapp-webview-huawei","quickapp-webview-union"],mc={platforms:zh.reduce((e,t)=>{e[t]=t;let r=t.replace(/^mp-/,"");return r&&r!==t&&(e[r]=t),e},{mp:"mp",app:"app",quickapp:"quickapp",h5:"h5",web:"h5"})};function hc(){return[{name:"unocss-preset-unix-platforms",match(t,r){let n=Y("uni-",t,r.generator.config.separators);if(n){let[o,a]=n,i=p.bracket(o)??o,{platforms:s={}}=r.theme;if(i){let c=o.startsWith("not-"),l=c?o.slice(4):o;if(p.bracket(o)?l=p.bracket(o)??"":l===""&&(l=s[c?o.slice(4):o]??""),l){let u=process.env.UNI_PLATFORM,d=Eh(u,l);return(c?!d:d)?{matcher:a}:null}}}},multiPass:!0,autocomplete:"uni-$platforms:"}]}function Eh(e,t){if(!e)return!1;let r=Ch(t);for(let n of r)if(re&&n==="appx"||(n==="h5"||n==="web")&&(e==="h5"||e==="web")||e!==void 0&&e.startsWith(n))return!0;return!1}function Ch(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1).split(",").map(r=>r.trim()).filter(r=>r):[e]}var jh=/[\s'"`;]+/g;function _h(e=[]){if(!e.length)return/<\w(?=.*>)[\w:.$-]*\s(((".*?>?.*?")|.*?)*?)\/?>/gs;let t=e.flatMap(n=>{let o=n.toLowerCase(),a=o.charAt(0).toUpperCase()+o.slice(1),i=`${o}-`;return[a,i]}),r=t.length?`(?!${t.join("|")})`:"";return new RegExp(`<${r}\\w(?=.*>)[\\w:.$-]*\\s(((".*?>?.*?")|.*?)*?)\\/?>`,"gs")}var Ah=/([[?\w\u00A0-\uFFFF-:()#%.\]]+)(?:\s*=\s*('[^']*'|"[^"]*"|\S+))?/g,Rh=["placeholder","setup","lang","scoped"];function gc(e={}){let t=e?.ignoreAttributes??Rh,r=e?.nonValuedAttribute??!0,n=e.prefix??"un-",o=e.prefixedOnly??!1,a=e.deleteAttributes??!0,i=_h(e.ignoreTagPrefixes??[]);return{name:"transformer-attributify",enforce:"pre",async transform(s,c,{uno:l}){if(!/\.vue$/.test(c))return;let u=new Ke(s.toString()),d=u.original.matchAll(i);for(let h of d){let m=h.index,g=h[0],b="",k=[],w=Array.from((h[1]||"").matchAll(Ah));for(let x of w){let S=x[0],_=x[1];if(_.startsWith(":"))continue;let E=x[2],C=_.replace(n,"");if(!t.includes(C))if(E){if(_.includes("hover-class"))continue;if(["class","className"].includes(_))_.includes(":")||(b=E.replace(/['"`]/g,""));else{if(o&&n&&!_.startsWith(n))continue;let N=[];for(let H of E.split(jh).filter(Boolean)){let ye=H;if(H.includes(":")){let Z=H.split(":");ye=`${Z[0]}:${Z[1]}`,await l.parseToken(`${C}-${Z[1]}`)?N.push(`${Z[0]}:${C}-${Z[1]}`):await l.parseToken(`${Z[0]}:${Z[1]}`)&&N.push(`${Z[0]}:${Z[1]}`)}else H==="~"?ye=C:H.startsWith("!")?ye=`!${C}-${H.slice(1)}`:ye=`${C}-${H}`,await l.parseToken(ye)&&N.push(ye)}k.push(...N),N.length&&a&&(g=g.replace(` ${S}`,""))}}else{if(o&&n&&!_.startsWith(n))continue;Te(C)&&r&&await l.parseToken(C)&&(k.push(C),a&&(g=g.replace(` ${_}`,"")))}}if(k.length){if(b)g=g.replace(`"${b}"`,`"${b} ${k.join(" ")}"`);else{let x=g.endsWith("/>")?-2:-1;g=`${g.slice(0,x)} class="${k.join(" ")}"${g.slice(x)}`}u.overwrite(m,m+h[0].length,g)}}s.overwrite(0,s.original.length,u.toString())}}}var Ph=/(?<!<!--\s*)/,Oh=/<style([^>]*)>[\s\S]*?<\/style\s*>/,Mh=new RegExp(Ph.source+Oh.source,"g"),Fh=e=>({name:"unocss-inline-style",enforce:"pre",async transform(t,r,{uno:n,tokens:o}){if(!re||!oa)return;let a=r.split(".").pop();if(a!=="uvue"&&a!=="vue"||!t.original.length)return;let i=t.toString(),c=(await n.generate(i,{preflights:!0})).getLayers(e?.includeLayers??["theme","default"],e?.excludeLayers);if(!c)return;let l=i.match(Mh),u;l?u=i.replace(/(<\/style\s*>)/,`${c}
413
413
  $1`):u=`${i}
414
414
  <style>
415
415
  ${c}
416
- </style>`,t.overwrite(0,t.original.length,u)}}),Th=(e={})=>{let r=[...Vn,...e.unsupportedChars??[]].map(s=>T(s)),n=/^-+/,o=new RegExp(`[${r.join("")}]`),a=new RegExp(o,"g");function i(s){let c=s.replace(/<[^>]*>/g,""),l=ac(c,o,a);l=Wn(l);let u=l.replace(n,"");return{cleanOriginal:c,replacedKey:u}}return{name:"char-only-class-transformer",enforce:"pre",async transform(s,c,l){if(!Me&&!re||!/\.(uvue|vue)($|\?)/.test(c))return;let u=s.toString(),{uno:d,tokens:h}=l,{matched:m}=await d.generate(u,{preflights:!1}),g=u,b=Array.from(m).filter(E=>o.test(E)).filter(E=>!E.includes("=")||E.includes("[url(")),k=new Map;for(let E of b){let{cleanOriginal:C,replacedKey:N}=i(E),ye=(await d.parseToken(C))?.[0]?.[4]?.layer,Z=E.replace(n,"");d.config.shortcuts.push([N,Z,{layer:ye}]),h.add(N),k.set(C,N),e.isGlobal&&(g=g.replaceAll(Z,N))}if(e.isGlobal){s.overwrite(0,s.original.length,g);return}function w(E){return E.split(/\s+/).map(C=>k.get(C)||C).join(" ")}function x(E,C){let N=C==='"'?"'":'"',H=new RegExp(`${N}([^${N}]*)${N}`,"g");return E.replace(H,(ye,Z)=>{let Wc=w(Z);return`${N}${Wc}${N}`})}let S=/\s(class|:class|hover-class|:hover-class)="([^"]*)"/g,_=/\s(class|:class|hover-class|:hover-class)='([^']*)'/g;g=g.replace(S,(E,C,N)=>{if(C.startsWith(":")){let H=x(N,'"');return` ${C}="${H}"`}else{let H=w(N);return` ${C}="${H}"`}}),g=g.replace(_,(E,C,N)=>{if(C.startsWith(":")){let H=x(N,"'");return` ${C}='${H}'`}else{let H=w(N);return` ${C}='${H}'`}}),s.overwrite(0,s.original.length,g)}}},Lh=()=>({name:"line-clamp-transformer",enforce:"pre",transform(e,t){return!Nt||!/\.(uvue|vue)($|\?)/.test(t)?e:e.replace(/<text([^>]*class="[^"]*line-clamp-(\d+)[^"]*"[^>]*)>/g,(r,n,o)=>n.includes("max-lines")||n.includes(":max-lines")?r:`<text${n} :max-lines="${o}">`)}}),Wh=()=>({name:"line-clamp-redirect-transformer",enforce:"pre",transform(e,t){return!re||!/\.(uvue|vue)($|\?)/.test(t)?e:e.replace(/class="([^"]*line-clamp-(\d+)[^"]*)"/g,(r,n,o)=>`class="${n.replace(/line-clamp-(\d+)/g,(a,i)=>`max-lines-${i}`)}"`)}});function bc(e){let t=[];if(Me&&e.attributify&&t.push(gc(e.attributify)),(Me||re)&&e.classCharReplace!==!1){let r={unsupportedChars:e.unsupportedChars};e.classCharReplace==="global"?r.isGlobal=!0:e.classCharReplace==="class"&&(r.isGlobal=!1),t.push(Th(r))}return Nt&&t.push(Lh()),re&&t.push(Wh()),re&&oa&&e.inlineStyle&&t.push(Fh(e.inlineStyleLayers)),t}function yc(){return[[/^max-lines-(\d+)$/,([,e])=>Nt?{"text-overflow":"ellipsis"}:{lines:e,"text-overflow":"ellipsis"}]]}var Qy=(e={})=>{let t=tc(e),r=fc(t),n=hc(),o=bc(t),a=yc();return{name:"lime-unocss-preset",presets:r,variants:n,theme:mc,rules:a,configResolved(i){let s=dc(t,i.root);i.postprocess?i.postprocess=[...i.postprocess,...s]:i.postprocess=s,i.transformers?i.transformers=[...i.transformers,...o]:i.transformers=o}}};function Ut(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Un(e){return{50:1,100:2,200:3,300:4,400:5,500:6,600:7,700:8,800:9,900:10}[e]||6}var Dt=Gc(Sc(),1),Hn=2,zc=.16,Nh=.05,Uh=.05,Ih=.15,Ac=5,Rc=4,Dh=[{index:7,amount:15},{index:6,amount:25},{index:5,amount:30},{index:5,amount:45},{index:5,amount:65},{index:5,amount:85},{index:4,amount:90},{index:3,amount:95},{index:2,amount:97},{index:1,amount:98}];function Ec(e,t,r){let n;return Math.round(e.h)>=60&&Math.round(e.h)<=240?n=r?Math.round(e.h)-Hn*t:Math.round(e.h)+Hn*t:n=r?Math.round(e.h)+Hn*t:Math.round(e.h)-Hn*t,n<0?n+=360:n>=360&&(n-=360),n}function Cc(e,t,r){if(e.h===0&&e.s===0)return e.s;let n;return r?n=e.s-zc*t:t===Rc?n=e.s+zc:n=e.s+Nh*t,n>1&&(n=1),r&&t===Ac&&n>.1&&(n=.1),n<.06&&(n=.06),Math.round(n*100)/100}function jc(e,t,r){let n;return r?n=e.v+Uh*t:n=e.v-Ih*t,n=Math.max(0,Math.min(1,n)),Math.round(n*100)/100}function _c(e,t={}){let r=[],n=new Dt.FastColor(e),o=n.toHsv();for(let a=Ac;a>0;a-=1){let i=new Dt.FastColor({h:Ec(o,a,!0),s:Cc(o,a,!0),v:jc(o,a,!0)});r.push(i)}r.push(n);for(let a=1;a<=Rc;a+=1){let i=new Dt.FastColor({h:Ec(o,a),s:Cc(o,a),v:jc(o,a)});r.push(i)}return t.theme==="dark"?Dh.map(({index:a,amount:i})=>new Dt.FastColor(t.backgroundColor||"#141414").mix(r[a],i).toHexString()):r.map(a=>a.toHexString())}function Pc(e,t){try{let r=_c(e,{theme:"default"}),n=_c(e,{theme:"dark",backgroundColor:t});return!r||!n?(console.error("Failed to generate colors"),{light:[],dark:[]}):{light:r,dark:n}}catch(r){return console.error("Error in generateLightDarkColors:",r),{light:[],dark:[]}}}function Oc(e,t,r){if(typeof e=="string"&&e.startsWith("@")){let n=e.substring(1),o=`${r}-${n}`,a=t.get(n);return`var(${o}${a?`, ${a}`:""})`}return e}function Mc(e,t,r,n,o,a,i=!0){if(!i){let s=n?o:a;Array.isArray(e)?s.set(t,e[0]):s.set(t,e);return}if(Array.isArray(e)){let s=n?o:a;e.forEach((c,l)=>{s.set(`${t}-color-${l+1}`,c)}),e[5]&&s.set(`${t}-color`,e[5])}else{let{light:s,dark:c}=Pc(e,r),l=n?s:c;l&&Array.isArray(l)&&l.forEach((u,d)=>{n?o.set(`${t}-color-${d+1}`,u):a.set(`${t}-color-${d+1}`,u)}),l&&l[5]&&(n?o.set(`${t}-color`,l[5]):a.set(`${t}-color`,l[5]))}}function Fc(e,t,r,n,o){return[[new RegExp(`^${e}:(.*):`),a=>{let i=a?.[1];if(!i)return{};let s=i==="dark"?o:n,c={};return s.forEach((l,u)=>{c[`${r}-${u}`]=l}),c}],[new RegExp(`^bg-(${t})-(50|100|200|300|400|500|600|700|800|900)$`),([,a,i])=>{let s=Un(i),c=`${r}-${a}-color-${s}`,l=`${a}-color-${s}`,u=n.get(l),d=u?`, ${u}`:"";return{"background-color":`var(${c}${d})`}}],[new RegExp(`^text-(${t})-(50|100|200|300|400|500|600|700|800|900)$`),([,a,i])=>{let s=Un(i),c=`${r}-${a}-color-${s}`,l=`${a}-color-${s}`,u=n.get(l),d=u?`, ${u}`:"";return{color:`var(${c}${d})`}}],[new RegExp(`^border-(${t})-(50|100|200|300|400|500|600|700|800|900)$`),([,a,i])=>{let s=Un(i),c=`${r}-${a}-color-${s}`,l=`${a}-color-${s}`,u=n.get(l),d=u?`, ${u}`:"";return{"border-color":`var(${c}${d})`}}]]}function Tc(e,t){return{name:"preset-theme-rule",match(r){if(r.includes(e))return{matcher:r,selector(n){let o=n.match(/:([\w-]+)\\:\d+/)?.[1];return t[o]||`.${o}`}}}}}async function Hh(e,t,r,n,o){let{css:a}=await o.generator.generate(t.map(u=>`${u}:${e}:${u}:${Date.now()}`),{preflights:!1});if(!a)return"";let i="",s=[],l=Object.keys(n).length>0?r:{light:":root,page,.l-portal",dark:".dark"};return a.replace(/,\n/g,",").split(`
416
+ </style>`,t.overwrite(0,t.original.length,u)}}),Th=(e={})=>{let r=[...Vn,...e.unsupportedChars??[]].map(s=>T(s)),n=/^-+/,o=new RegExp(`[${r.join("")}]`),a=new RegExp(o,"g");function i(s){let c=s.replace(/<[^>]*>/g,""),l=ac(c,o,a);l=Wn(l);let u=l.replace(n,"");return{cleanOriginal:c,replacedKey:u}}return{name:"char-only-class-transformer",enforce:"pre",async transform(s,c,l){if(!Me&&!re||!/\.(uvue|vue)($|\?)/.test(c)||!s.original.length)return;let u=s.toString(),{uno:d,tokens:h}=l,{matched:m}=await d.generate(u,{preflights:!1}),g=u,b=Array.from(m).filter(E=>o.test(E)).filter(E=>!E.includes("=")||E.includes("[url(")),k=new Map;for(let E of b){let{cleanOriginal:C,replacedKey:N}=i(E),ye=(await d.parseToken(C))?.[0]?.[4]?.layer,Z=E.replace(n,"");d.config.shortcuts.push([N,Z,{layer:ye}]),h.add(N),k.set(C,N),e.isGlobal&&(g=g.replaceAll(Z,N))}if(e.isGlobal){s.overwrite(0,s.original.length,g);return}function w(E){return E.split(/\s+/).map(C=>k.get(C)||C).join(" ")}function x(E,C){let N=C==='"'?"'":'"',H=new RegExp(`${N}([^${N}]*)${N}`,"g");return E.replace(H,(ye,Z)=>{let Wc=w(Z);return`${N}${Wc}${N}`})}let S=/\s(class|:class|hover-class|:hover-class)="([^"]*)"/g,_=/\s(class|:class|hover-class|:hover-class)='([^']*)'/g;g=g.replace(S,(E,C,N)=>{if(C.startsWith(":")){let H=x(N,'"');return` ${C}="${H}"`}else{let H=w(N);return` ${C}="${H}"`}}),g=g.replace(_,(E,C,N)=>{if(C.startsWith(":")){let H=x(N,"'");return` ${C}='${H}'`}else{let H=w(N);return` ${C}='${H}'`}}),s.overwrite(0,s.original.length,g)}}},Lh=()=>({name:"line-clamp-transformer",enforce:"pre",transform(e,t){return!Nt||!/\.(uvue|vue)($|\?)/.test(t)?e:e.replace(/<text([^>]*class="[^"]*line-clamp-(\d+)[^"]*"[^>]*)>/g,(r,n,o)=>n.includes("max-lines")||n.includes(":max-lines")?r:`<text${n} :max-lines="${o}">`)}}),Wh=()=>({name:"line-clamp-redirect-transformer",enforce:"pre",transform(e,t){return!re||!/\.(uvue|vue)($|\?)/.test(t)?e:e.replace(/class="([^"]*line-clamp-(\d+)[^"]*)"/g,(r,n,o)=>`class="${n.replace(/line-clamp-(\d+)/g,(a,i)=>`max-lines-${i}`)}"`)}});function bc(e){let t=[];if(Me&&e.attributify&&t.push(gc(e.attributify)),(Me||re)&&e.classCharReplace!==!1){let r={unsupportedChars:e.unsupportedChars};e.classCharReplace==="global"?r.isGlobal=!0:e.classCharReplace==="class"&&(r.isGlobal=!1),t.push(Th(r))}return Nt&&t.push(Lh()),re&&t.push(Wh()),re&&oa&&e.inlineStyle&&t.push(Fh(e.inlineStyleLayers)),t}function yc(){return[[/^max-lines-(\d+)$/,([,e])=>Nt?{"text-overflow":"ellipsis"}:{lines:e,"text-overflow":"ellipsis"}]]}var Qy=(e={})=>{let t=tc(e),r=fc(t),n=hc(),o=bc(t),a=yc();return{name:"lime-unocss-preset",presets:r,variants:n,theme:mc,rules:a,configResolved(i){let s=dc(t,i.root);i.postprocess?i.postprocess=[...i.postprocess,...s]:i.postprocess=s,i.transformers?i.transformers=[...i.transformers,...o]:i.transformers=o}}};function Ut(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Un(e){return{50:1,100:2,200:3,300:4,400:5,500:6,600:7,700:8,800:9,900:10}[e]||6}var Dt=Gc(Sc(),1),Hn=2,zc=.16,Nh=.05,Uh=.05,Ih=.15,Ac=5,Rc=4,Dh=[{index:7,amount:15},{index:6,amount:25},{index:5,amount:30},{index:5,amount:45},{index:5,amount:65},{index:5,amount:85},{index:4,amount:90},{index:3,amount:95},{index:2,amount:97},{index:1,amount:98}];function Ec(e,t,r){let n;return Math.round(e.h)>=60&&Math.round(e.h)<=240?n=r?Math.round(e.h)-Hn*t:Math.round(e.h)+Hn*t:n=r?Math.round(e.h)+Hn*t:Math.round(e.h)-Hn*t,n<0?n+=360:n>=360&&(n-=360),n}function Cc(e,t,r){if(e.h===0&&e.s===0)return e.s;let n;return r?n=e.s-zc*t:t===Rc?n=e.s+zc:n=e.s+Nh*t,n>1&&(n=1),r&&t===Ac&&n>.1&&(n=.1),n<.06&&(n=.06),Math.round(n*100)/100}function jc(e,t,r){let n;return r?n=e.v+Uh*t:n=e.v-Ih*t,n=Math.max(0,Math.min(1,n)),Math.round(n*100)/100}function _c(e,t={}){let r=[],n=new Dt.FastColor(e),o=n.toHsv();for(let a=Ac;a>0;a-=1){let i=new Dt.FastColor({h:Ec(o,a,!0),s:Cc(o,a,!0),v:jc(o,a,!0)});r.push(i)}r.push(n);for(let a=1;a<=Rc;a+=1){let i=new Dt.FastColor({h:Ec(o,a),s:Cc(o,a),v:jc(o,a)});r.push(i)}return t.theme==="dark"?Dh.map(({index:a,amount:i})=>new Dt.FastColor(t.backgroundColor||"#141414").mix(r[a],i).toHexString()):r.map(a=>a.toHexString())}function Pc(e,t){try{let r=_c(e,{theme:"default"}),n=_c(e,{theme:"dark",backgroundColor:t});return!r||!n?(console.error("Failed to generate colors"),{light:[],dark:[]}):{light:r,dark:n}}catch(r){return console.error("Error in generateLightDarkColors:",r),{light:[],dark:[]}}}function Oc(e,t,r){if(typeof e=="string"&&e.startsWith("@")){let n=e.substring(1),o=`${r}-${n}`,a=t.get(n);return`var(${o}${a?`, ${a}`:""})`}return e}function Mc(e,t,r,n,o,a,i=!0){if(!i){let s=n?o:a;Array.isArray(e)?s.set(t,e[0]):s.set(t,e);return}if(Array.isArray(e)){let s=n?o:a;e.forEach((c,l)=>{s.set(`${t}-color-${l+1}`,c)}),e[5]&&s.set(`${t}-color`,e[5])}else{let{light:s,dark:c}=Pc(e,r),l=n?s:c;l&&Array.isArray(l)&&l.forEach((u,d)=>{n?o.set(`${t}-color-${d+1}`,u):a.set(`${t}-color-${d+1}`,u)}),l&&l[5]&&(n?o.set(`${t}-color`,l[5]):a.set(`${t}-color`,l[5]))}}function Fc(e,t,r,n,o){return[[new RegExp(`^${e}:(.*):`),a=>{let i=a?.[1];if(!i)return{};let s=i==="dark"?o:n,c={};return s.forEach((l,u)=>{c[`${r}-${u}`]=l}),c}],[new RegExp(`^bg-(${t})-(50|100|200|300|400|500|600|700|800|900)$`),([,a,i])=>{let s=Un(i),c=`${r}-${a}-color-${s}`,l=`${a}-color-${s}`,u=n.get(l),d=u?`, ${u}`:"";return{"background-color":`var(${c}${d})`}}],[new RegExp(`^text-(${t})-(50|100|200|300|400|500|600|700|800|900)$`),([,a,i])=>{let s=Un(i),c=`${r}-${a}-color-${s}`,l=`${a}-color-${s}`,u=n.get(l),d=u?`, ${u}`:"";return{color:`var(${c}${d})`}}],[new RegExp(`^border-(${t})-(50|100|200|300|400|500|600|700|800|900)$`),([,a,i])=>{let s=Un(i),c=`${r}-${a}-color-${s}`,l=`${a}-color-${s}`,u=n.get(l),d=u?`, ${u}`:"";return{"border-color":`var(${c}${d})`}}]]}function Tc(e,t){return{name:"preset-theme-rule",match(r){if(r.includes(e))return{matcher:r,selector(n){let o=n.match(/:([\w-]+)\\:\d+/)?.[1];return t[o]||`.${o}`}}}}}async function Hh(e,t,r,n,o){let{css:a}=await o.generator.generate(t.map(u=>`${u}:${e}:${u}:${Date.now()}`),{preflights:!1});if(!a)return"";let i="",s=[],l=Object.keys(n).length>0?r:{light:":root,page,.l-portal",dark:".dark"};return a.replace(/,\n/g,",").split(`
417
417
  `).slice(1).forEach(u=>{if(u==="@media (prefers-color-scheme: dark){"){i=l.dark||".dark",s.push(u);return}if(u==="@media (prefers-color-scheme: light){"){i=l.light,s.push(u);return}if(i&&u==="}"){i="",s[s.length-1]+=u;return}if(i){if(u.startsWith(`${i}{`)){s[s.length-1]+=u.replace(`${i}{`,":root,page,.l-portal{");return}return}let d=new RegExp(t.map(m=>{let g=l[m]||`.${m}`;return`((.${m}) ((${Ut(g)}[{|,])|(.${m}\\\\:)))`}).join("|"),"g"),h=u.replace(d,(m,...g)=>{let b=g.slice(0,-2),k="";for(let w=0;w<b.length/5;w++){let x=w*5;if(b[x]){if(b[x+3])k=b[x+3];else{let S=b[x+1].substring(1);k=`${l[S]||`.${S}`} ${b[x+2]}`}break}}return k});s.push(h)}),s.sort((u,d)=>{let h=`^${l.light}|^@media \\(prefers-color-scheme:`;return u.match(h)?.length?d.match(h)?.length?0:-1:1}).join(`
418
418
  `)}function Lc(e,t,r,n){return[{layer:"theme",async getCSS(o){return Hh(e,t,r,n,o)}}]}var pa="PRESET_THEME_RULE",qh=["dark","light"],Gh=new Map,Xh="--l";function wx(e){try{let{theme:t,prefix:r="--l",selectors:n={},darkBackgroundColor:o="#141414"}=e;Xh=r;let a=new Map,i=new Map;Gh=a;let s=(m,g,b,k=!0)=>{m&&Object.keys(m).forEach(w=>{try{let x=m[w];Mc(x,w,o,b,a,i,k)}catch(x){console.error(`Error generating colors for ${w}:`,x)}})};s(t.colors,a,!0),s(t.colors,i,!1),s(t.light?.colors,a,!0),s(t.dark?.colors,i,!1);let c=new Set([...a.keys(),...i.keys()].map(m=>m.replace(/-color-\d+$/,"").replace(/-color$/,""))),l=Array.from(c);s(t.light?.var,a,!0,!1),s(t.dark?.var,i,!1,!1);let u={light:":root,page,.l-portal",dark:".dark",...n},h=l.map(m=>Ut(m)).join("|");return{name:"lime-preset-theme",extendTheme(m){let g={};return l.forEach(b=>{let k=`${r}-${b}-color`,w=`${b}-color`;if(a.has(w)){let x=a.get(w);g[b]=`var(${k}, ${x})`}}),{...m,colors:{...m.colors,...g}}},rules:Fc(pa,h,r,a,i),variants:[Tc(pa,u)],preflights:Lc(pa,qh,u,n),postprocess(m){let g=new RegExp(`var\\((${Ut(r)}[\\w-]*)\\)`);m.entries.forEach(([,b])=>{if(typeof b=="string"){let k=b.match(g)?.[1];if(k){let w=k.replace(`${r}-`,"");a.has(w)||i.has(w)}}}),m.entries.forEach(([b,k])=>{if(typeof k=="string"){let w=Oc(k,a,r);w!==k&&(m.entries[m.entries.findIndex(([x])=>x===b)][1]=w)}})},layers:{theme:0,default:1}}}catch(t){return console.error("Error in presetTheme:",t),{name:"lime-preset-theme",extendTheme:r=>r,rules:[],preflights:[]}}}export{re as isAPPX,Zb as isApp,gh as isAppAndroid,hh as isAppHarmony,bh as isAppIOS,oa as isDev,Me as isMp,mh as isUniappx,Nt as isVapor,Jb as isWeb,wx as presetTheme,Qy as presetUnix};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "lime-unocss-preset",
3
3
  "name": "@limeui/unocss-preset",
4
4
  "displayName": "lime-unocss-preset - UnoCSS 预设",
5
- "version": "0.0.6",
5
+ "version": "0.0.7",
6
6
  "description": "让 UnoCSS 支持 uni-app 和 uni-app x,提供平台条件样式等特性",
7
7
  "type": "module",
8
8
  "main": "./dist/index.js",