transform-to-unocss-core 0.0.1
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 +25 -0
- package/cli.mjs +2 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/license +21 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## starter-ts
|
|
2
|
+
|
|
3
|
+
forked by [antfu/starter-ts](https://github.com/antfu/vitesse)
|
|
4
|
+
|
|
5
|
+
## GitHub Template
|
|
6
|
+
|
|
7
|
+
[Create a repo from this template on GitHub.](https://github.com/Simon-He95/starter-ts/generate)
|
|
8
|
+
|
|
9
|
+
## Clone to local
|
|
10
|
+
|
|
11
|
+
If you prefer to do it manually with the cleaner git history
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npx degit Simon-He95/starter-ts my-starter-ts-app
|
|
15
|
+
cd my-vitesse-app
|
|
16
|
+
pnpm i # If you don't have pnpm installed, run: npm install -g pnpm
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
[MIT](./LICENSE) License © 2022 [Simon He](https://github.com/Simon-He95)
|
|
22
|
+
|
|
23
|
+
<a href="https://github.com/Simon-He95/sponsor" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" style="height: 51px !important;width: 217px !important;" ></a>
|
|
24
|
+
|
|
25
|
+
<span><div align="center"></div></span>
|
package/cli.mjs
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.defineProperty;var Vr=Object.getOwnPropertyDescriptor;var Lr=Object.getOwnPropertyNames;var _r=Object.prototype.hasOwnProperty;var Fr=(r,o)=>{for(var t in o)T(r,t,{get:o[t],enumerable:!0})},zr=(r,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of Lr(o))!_r.call(r,e)&&e!==t&&T(r,e,{get:()=>o[e],enumerable:!(n=Vr(o,e))||n.enumerable});return r};var Sr=r=>zr(T({},"__esModule",{value:!0}),r);var Xr={};Fr(Xr,{toUnocss:()=>S,transformStyleToUnocss:()=>Nr});module.exports=Sr(Xr);function C(r){return r.startsWith("calc(")}function c(r){return r.split("-")[0]}function u(r){let o=r.split("-");return o[o.length-1]}function Tr(r){return r.startsWith("url(")}function U(r){return r.endsWith("%")}function Cr(r){return/^#[0-9A-Fa-f]{2,}$/.test(r)}function x(r){return r.startsWith("rgb")}function a(r,o,t){return C(r)||Tr(r)||Cr(r)||x(r)||U(r)?t?`-[${f(r,"all").replace(/['"]/g,"")}]`:`="[${f(r,"all").replace(/['"]/g,"")}]"`:`-${o?o(r):r}`}function h(r){return+r*100}function w(r){return r.replace(/\s+/," ").split(" ").join("-")}function I(r){return r.replace(/\s+/," ").split(" ").join("_")}function f(r,o="around"){return o==="pre"?r.replace(/(^\s*)/g,""):o==="post"?r.replace(/(\s*$)/g,""):o==="all"?r.replace(/\s+/g,""):o==="around"?r.replace(/(^\s*)|(\s*$)/g,""):r}function i(r){return r.endsWith("!important")?[r.replace(/\s*\!important/,"").trim(),"!"]:[r.trim(),""]}function B(r){return r.replace(/\(\s*/g,"(").replace(/\s*\)/g,")").replace(/\s*,\s*/g,",")}function L(r,o){let[t,n]=i(o);return`${r[0]}${a(t,c)}${n}`}var Ur=["background-color","background-size","background-attachment","background-position","background-image"],Pr=/linear-gradient\(\s*to([\w\s]+),?([\w\(\)#%\s\.]+)?,([\w\(\)#%\s\.]+)?,?([\w#%\s\.]+)?\)$/,Rr=/(radial|conic)-gradient\(([\w\(\)#%\s\.]+)?,([\w\(\)#%\s\.]+)?,?([\w#%\s\.]+)?\)$/,N="__comma__";function H(r,o){let[t,n]=i(o);if(Ur.includes(r))return`bg${a(t,E)}${n}`;if(r==="background"){if(/(linear)-gradient/.test(t)){let p=t.replace(/rgba?\(([\w\s,]+)\)/g,(j,W)=>j.replace(W,W.replace(/\s*,\s*/g,N))).match(Pr);if(!p)return;let[l,$,b,V]=p.slice(1);return l=f(l,"around").split(" ").map(j=>j[0]).join(""),l?`bg-gradient-to-${l}${P($,b,V)}`:P($,b,V)}else if(/(radial|conic)-gradient/.test(t)){let p=t.replace(/rgba?\(([\w\s,]+)\)/g,(j,W)=>j.replace(W,W.replace(/\s*,\s*/g,N))).match(Rr);if(!p)return;let l=p[1],[$,b,V]=p.slice(2);return`bg-gradient-${l}${P($,b,V)}`}let e=t.match(/rgba?\([\w,\s]+\)/);if(e){let m=e[0];return`bg="${t.replace(m,`[${f(m,"all")}]`)}${n}"`}let s=t.match(/url\(["'\s\.\-_\w\/]*\)/);return s?`bg="${t.replace(s[0],`[${s[0].replace(/['"]/g,"")}]${n}`)}"`:`bg="${t}${n}"`}return r==="background-blend-mode"?`bg-blend-${t}${n}`:`${Ar(r,t)}-${Mr(t)}${n}`}function Ar(r,o){return o.endsWith("repeat")?"bg":r.replace("background","bg")}function Mr(r){return/(border)|(content)|(padding)-box/.test(r)?r.replace("-box",""):r.startsWith("repeat-")?r.replace("repeat-",""):E(r)}function E(r){return r.replace(/\s+/," ").replace(" ","-")}function P(r,o,t){let n="";if(o&&!t&&(t=o,o=""),r){r=r.replaceAll(N,",");let[e,s]=f(r,"around").replace(/rgba?\(([\w,\s]+)\)/,(m,p)=>m.replace(p,f(p,"all"))).split(" ");s?n+=` from="${x(e)?`[${e}]`:e} ${s}"`:e&&(n+=` from="${x(e)?`[${e}]`:e}"`)}if(o){o=o.replaceAll(N,",");let[e,s]=f(o,"around").replace(/rgba?\(([\w,\s]+)\)/,(m,p)=>m.replace(p,f(p,"all"))).split(" ");s?n+=` via="${x(e)?`[${e}]`:e} ${s}"`:e&&(n+=` via="${x(e)?`[${e}]`:e}"`)}if(t){t=t.replaceAll(N,",");let[e,s]=f(t,"around").replace(/rgba?\(([\w,\s]+)\)/,(m,p)=>m.replace(p,f(p,"all"))).split(" ");s?n+=` to="${x(e)?`[${e}]`:e} ${s}"`:e&&(n+=` to="${x(e)?`[${e}]`:e}"`)}return n}function R(r,o){let[t,n]=i(o),e=r.split("-");return`${e[0]}-${e[1][0]}${a(c(t))}${n}`}function G(r,o){let[t,n]=i(o);if(r==="font-size")return`text-${t}${n}`;if(r==="font-weight")return`font-${t}${n}`;if(r==="font-family"){let e=t.match(/ui-(\w{0,4})/);if(!e)return`font-${o}${n}`;let[s,m]=e;return`font-${m}${n}`}return r==="font-style"?t==="normal"?`font-not-italic${n}`:`font-${t}${n}`:r==="font-variant-numeric"?t==="normal"?`normal-nums${n}`:`${t}${n}`:`font="${Br(t)}${n}"`}function Br(r){return r.split(" ").map(o=>/^[0-9]/.test(o)?`text-${o}`:o).join(" ")}function D(r,o){let[t,n]=i(o);return`${r}${a(t)}${n}`}var Hr={"margin-left":"ml","margin-right":"mr","margin-top":"mt","margin-bottom":"mb","margin-inline-start":"ms","margin-inline-end":"me","padding-left":"pl","padding-right":"pr","padding-top":"pt","padding-bottom":"pb","padding-inline-start":"ps","padding-inline-end":"pe"};function A(r,o){let[t,n]=i(o),e=Hr[r];if(e)return`${e}${a(t)}${n}`;let s=f(t).split(" "),m=s.length;return m===1?`${r[0]}${a(s[0])}${n}`:m===2?`${r[0]}x${a(s[1])}${n} ${r[0]}y${a(s[0])}${n}`:m===3?`${r[0]}x${a(s[1])}${n} ${r[0]}t${a(s[0])}${n} ${r[0]}b${a(s[2])}${n}`:`${r[0]}t${a(s[0])}${n} ${r[0]}b${a(s[2])}${n} ${r[0]}l${a(s[3])}${n} ${r[0]}r${a(s[1])}${n}`}function Z(r,o){let[t,n]=i(o);return U(o)?`op-${t.replace("%","")}${n}`:`op-${+t*100}${n}`}function q(r,o){let[t,n]=i(o);return`text${a(t)}${n}`}function J(r,o){let[t,n]=i(o);return r==="text-decoration-line"?t==="none"?`no-underline${n}`:`${t}${n}`:r==="text-transform"?t==="none"?`normal-case${n}`:`${t}${n}`:r.startsWith("text-decoration")||r==="text-indent"?`${r.split("-")[1]}-${t}${n}`:r==="text-underline-offset"?`underline-offset-${t}${n}`:`text-${t}${n}`}function K(r,o){let[t,n]=i(o);return`v-${t}${n}`}function O(r,o){let[t,n]=i(o);return`lh${a(t)}${n}`}var Er=["border-left","border-top","border-right","border-bottom"];function Q(r,o){let[t,n]=i(o);return r==="border-spacing"?`${r}="[${I(t)}]${n}"`:r==="border-color"?`border${a(t)}${n}`:r==="border-radius"?C(t)||!t.includes(" ")?`border-rd${a(t)}${n}`:`border-rd="[${I(t)}]${n}"`:Er.some(e=>r.startsWith(e))?`border-${r.split("-")[1][0]}${a(t)}${n}`:r==="border-inline-end-width"?`border-e${a(t)}${n}`:r==="border-inline-start-width"?`border-s${a(t)}${n}`:r.startsWith("border-image")?"":/^\d[%|(px)|(rem)]$/.test(t)||r==="border-collapse"?`border-${t}${n}`:r==="border-width"||r==="border-style"?`border${a(t)}${n}`:r==="border-color"?t==="currentColor"?`border-current${n}`:`border${a(t)}${n}`:(/rgb/.test(t)&&(t=t.replace(/rgb[a](.*)/,(e,s)=>e.replace(s,f(s,"all")))),`border="[${I(t)}]${n}"`)}function _(r,o){let[t,n]=i(o);return t==="none"?`hidden${n}`:t==="hidden"?`invisible${n}`:`${t}${n}`}function g(r,o){let[t,n]=i(o);return`${r}-${t}${n}`}function v(r,o){let[t,n]=i(o);return`${r}${a(t)}${n}`}function d(r,o){let[t,n]=i(o);return`${c(r)}${a(t)}${n}`}function F(r,o){let[t,n]=i(o);if(r.startsWith("box-decoration"))return`box-decoration-${t}${n}`;if(r==="box-sizing")return`box-${c(t)}${n}`;let e=/rgba?(\([\w,\s.]+\))/g;return t=t.replace(e,(s,m)=>s.replace(m,f(m,"all"))).replace(/\s*,\s*/g,","),`shadow="[${t.replace(/\s+/," ").split(" ").join("_")}]${n}"`}var Gr=["contrast","brightness","saturate"],Dr=["grayscale","invert","sepia"];function z(r,o){let[t,n]=i(o),[e,s,m]=t.match(/([\w-]+)\((.*)\)/);return Gr.includes(s)?`${s}-${h(m)}${n}`:s==="drop-shadow"?`drop-${F(s,m)}${n}`:Dr.includes(s)?`${s}-${m.endsWith("%")?m.slice(0,-1):h(m)}${n}`:s==="hue-rotate"?`${s}-${m.slice(0,-3)}${n}`:`${s}-${m}${n}`}function X(r,o){let[t,n]=i(o);return`backdrop-${z(r,t)}${n}`}function y(r,o){let[t,n]=i(o);return r==="transform-origin"?`origin-${w(t)}${n}`:r==="transform-style"?`transform-${t}`:B(t).split(" ").map(e=>{let s=e.match(/([a-z]+)([A-Z])?\((.*)\)/);if(!s)return;let[m,p,l,$]=s;return l?p==="scale"?$.includes(",")?`${p}-${l.toLowerCase()}="${$.split(",").join(" ")}${n}"`:`${p}-${l.toLowerCase()}-${h($)}${n}`:`${p}-${l.toLowerCase()}="${Y($)}${n}"`:p==="scale"?$.includes(",")?`${p}="${$.split(",").join(" ")}${n}"`:`${p}-${h($)}${n}`:`${p}="${Y($).replace(/,/g," ")}${n}"`}).filter(Boolean).join(" ")}function Y(r){return r=f(r,"all"),r.endsWith("deg")?r.slice(0,-3):r}var Zr=["transition-delay","transition-duration"];function k(r,o){let[t,n]=i(o);if(r==="transition-timing-function")return t==="linear"?`ease-${t}${n}`:`ease="[${f(t,"all")}]${n}"`;if(r==="transition")return`transition="${qr(t)}"`;if(r==="transition-property")return t.includes("color")?`transition-color${n}`:t==="box-shadow"?`transition-shadow${n}`:`transition-${t}${n}`;if(Zr.includes(r))return`${r.split("-")[1]}-${t.slice(0,-2)}`}function qr(r){let o=!1;return r.split(" ").map(t=>/^[0-9]/.test(t)||/^\.[0-9]/.test(t)?o?`delay${a(t,void 0,!0)}`:(o=!0,`duration${a(t,void 0,!0)}`):t==="background-color"?"colors":t).join(" ")}function rr(r,o){let[t,n]=i(o);return r==="justify-content"?`justify-${u(t)}${n}`:`${r}-${u(t)}${n}`}function tr(r,o){let[t,n]=i(o);return`${u(r)}-${u(t)}${n}`}var Jr=["flex-basis","flex-grow","flex-shrink"];function nr(r,o){let[t,n]=i(o);if(Jr.includes(r))return`${u(r)}-${t}${n}`;if(t==="1")return`flex-1${n}`;let e=f(t)[0];return r==="flex"&&(e==="0"||e==="1")?`flex="[${I(t)}]${n}"`:`${c(r)}-${t.replace("column","col")}${n}`}function or(r,o){let[t,n]=i(o);return t==="auto"?`${c(r)}-${t}`:`${c(r)}="[${f(t,"all")}]${n}"`}function ir(r,o){let[t,n]=i(o);return r==="column-gap"?`gap-x-${t}${n}`:`${r}-${t}${n}`}function er(r,o){let[t,n]=i(o);return o==="isolate"?`${t}${n}`:`${r}-${t}${n}`}function sr(r,o){let[t,n]=i(o);return r==="object-position"?`${c(r)}-${w(t)}${n}`:`${c(r)}-${t}${n}`}function ar(r,o){let[t,n]=i(o),[e,s,m]=r.split("-");return m?`${e}-${m}-${t}${n}`:`${e}-${t}${n}`}function mr(r,o){let[t,n]=i(o);if(r.startsWith("grid-template")){let s=t.match(/repeat\s*\(\s*([0-9]+)/);return s?`grid-${u(r)==="rows"?"rows":"cols"}-${s[1]}${n}`:`grid-${u(r)==="rows"?"rows":"cols"}-${t}${n}`}if(r==="grid-auto-flow")return`grid-flow-${w(t).replace("column","col")}${n}`;if(r.startsWith("grid-auto")){let s=t.match(/minmax\s*\(\s*0\s*,\s*1fr/);return`auto-${u(r)==="rows"?"rows":"cols"}-${s?"fr":c(t)}${n}`}let e=t.match(/span\s+([0-9])/);return e?`${r.slice(5).replace("column","col")}-span-${e[1]}${n}`:f(t,"all")==="1/-1"?`${r.slice(5).replace("column","col")}-span-full${n}`:`${r.slice(5).replace("column","col")}-${t}${n}`}function pr(r,o){let[t,n]=i(o);return`gap-y-${t}${n}`}function fr(r,o){let[t,n]=i(o);return`${r}-${u(t)}${n}`}function cr(r,o){let[t,n]=i(o);return`tracking-${t}${n}`}function ur(r,o){let[t,n]=i(o);return`whitespace-${t}${n}`}function lr(r,o){let[t,n]=i(o);return r.startsWith("word-spacing")?`word-spacing${a(o)}`:t==="keep-all"?`break-keep${n}`:`break-${u(t)}${n}`}function $r(r,o){let[t,n]=i(o);return r==="outline-offset"?`${r}-${t}${n}`:`${c(r)}-${t}${n}`}function gr(r,o){let[t,n]=i(o);return`mix-blend-${t}${n}`}var Kr={vertical:"y",horizontal:"x"};function dr(r,o){let[t,n]=i(o);return t==="both"?`${r}${n}`:`${r}-${Kr[t]||t}${n}`}function xr(r,o){let[t,n]=i(o);if(r.startsWith("scroll-snap"))return`snap-${t}${n}`;if(r==="scroll-behavior")return`scroll-${t}${n}`;let[e,s,m,p]=r.match(/scroll-(margin|padding)-?([\w]+)?-?([\w]+)?/);return m==="inline"&&p?`scroll-${s[0]}${p[0]}-${t}${n}`:m?`scroll-${s[0]}${m[0]}-${t}${n}`:`scroll-${s[0]}-${t}${n}`}function br(r,o){let[t,n]=i(o);return`${u(r)}-${t}${n}`}function hr(r,o){let[t,n]=i(o);return`${r}-${c(t)}${n}`}function wr(r,o){let[t,n]=i(o);return r==="animation-delay"?`animate${a(t)}${n}`:r==="animation"?`animate-${t.split(" ")[0]}${n}`:`animate-${t}${n}`}function Ir(r,o){let[t,n]=i(o);return`content="[${t}]${n}"`}var Or={show:"visible",hide:"hidden"};function vr(r,o){var e;let[t,n]=i(o);return`table-empty-cells-${(e=Or[t])!=null?e:t}${n}`}function jr(r,o){return o==="horizontal-tb"?"write-normal":`write-${o.replace("-rl","-right").replace("-lr","-left")}`}function Wr(r,o){let[t,n]=i(o);if(r==="inset-inline-start")return`start${a(t)}${n}`;if(r==="inset-inline-end")return`end${a(t)}${n}`}var M={animation:wr,aspect:or,backface:d,caption:d,column:ir,columns:g,break:g,empty:vr,box:F,writing:jr,display:_,float:g,clear:g,isolation:er,object:sr,overflow:g,overscroll:ar,position:_,top:v,left:v,right:v,bottom:v,visibility:_,z:L,flex:nr,order:g,grid:mr,gap:v,justify:rr,align:tr,place:fr,padding:A,perspective:g,margin:A,width:L,min:R,max:R,height:L,font:G,letter:cr,line:O,list:d,text:J,vertical:K,white:ur,word:lr,content:Ir,background:H,border:Q,outline:$r,opacity:Z,mix:gr,filter:z,backdrop:X,table:d,transition:k,transform:y,accent:d,appearance:d,cursor:D,caret:d,pointer:g,resize:dr,scroll:xr,inset:Wr,touch:d,user:br,will:hr,fill:g,stroke:d,color:q,row:pr},Qr=/([\w-]+)\s*:\s*([.\w\(\)-\s%+'",#\/!]+)/;function S(r,o=!1){var l;let t=r.match(Qr);if(!t)return;let[n,e,s]=t,m=c(e),p=(l=M[m])==null?void 0:l.call(M,e,s);return p&&o?p.replace(/-([0-9\.]+)px/,($,b)=>`-${+b/4}`):p}function Nr(r,o){let t=[];return[r.split(";").filter(Boolean).reduce((n,e)=>{let s=S(e,o)||"";return s||t.push(e),n+=`${s} `},"").trim(),t]}0&&(module.exports={toUnocss,transformStyleToUnocss});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function S(r){return r.startsWith("calc(")}function c(r){return r.split("-")[0]}function u(r){let o=r.split("-");return o[o.length-1]}function Wr(r){return r.startsWith("url(")}function T(r){return r.endsWith("%")}function Nr(r){return/^#[0-9A-Fa-f]{2,}$/.test(r)}function x(r){return r.startsWith("rgb")}function a(r,o,t){return S(r)||Wr(r)||Nr(r)||x(r)||T(r)?t?`-[${f(r,"all").replace(/['"]/g,"")}]`:`="[${f(r,"all").replace(/['"]/g,"")}]"`:`-${o?o(r):r}`}function h(r){return+r*100}function w(r){return r.replace(/\s+/," ").split(" ").join("-")}function I(r){return r.replace(/\s+/," ").split(" ").join("_")}function f(r,o="around"){return o==="pre"?r.replace(/(^\s*)/g,""):o==="post"?r.replace(/(\s*$)/g,""):o==="all"?r.replace(/\s+/g,""):o==="around"?r.replace(/(^\s*)|(\s*$)/g,""):r}function i(r){return r.endsWith("!important")?[r.replace(/\s*\!important/,"").trim(),"!"]:[r.trim(),""]}function M(r){return r.replace(/\(\s*/g,"(").replace(/\s*\)/g,")").replace(/\s*,\s*/g,",")}function L(r,o){let[t,n]=i(o);return`${r[0]}${a(t,c)}${n}`}var Vr=["background-color","background-size","background-attachment","background-position","background-image"],Lr=/linear-gradient\(\s*to([\w\s]+),?([\w\(\)#%\s\.]+)?,([\w\(\)#%\s\.]+)?,?([\w#%\s\.]+)?\)$/,_r=/(radial|conic)-gradient\(([\w\(\)#%\s\.]+)?,([\w\(\)#%\s\.]+)?,?([\w#%\s\.]+)?\)$/,N="__comma__";function B(r,o){let[t,n]=i(o);if(Vr.includes(r))return`bg${a(t,H)}${n}`;if(r==="background"){if(/(linear)-gradient/.test(t)){let p=t.replace(/rgba?\(([\w\s,]+)\)/g,(j,W)=>j.replace(W,W.replace(/\s*,\s*/g,N))).match(Lr);if(!p)return;let[l,$,b,V]=p.slice(1);return l=f(l,"around").split(" ").map(j=>j[0]).join(""),l?`bg-gradient-to-${l}${C($,b,V)}`:C($,b,V)}else if(/(radial|conic)-gradient/.test(t)){let p=t.replace(/rgba?\(([\w\s,]+)\)/g,(j,W)=>j.replace(W,W.replace(/\s*,\s*/g,N))).match(_r);if(!p)return;let l=p[1],[$,b,V]=p.slice(2);return`bg-gradient-${l}${C($,b,V)}`}let e=t.match(/rgba?\([\w,\s]+\)/);if(e){let m=e[0];return`bg="${t.replace(m,`[${f(m,"all")}]`)}${n}"`}let s=t.match(/url\(["'\s\.\-_\w\/]*\)/);return s?`bg="${t.replace(s[0],`[${s[0].replace(/['"]/g,"")}]${n}`)}"`:`bg="${t}${n}"`}return r==="background-blend-mode"?`bg-blend-${t}${n}`:`${Fr(r,t)}-${zr(t)}${n}`}function Fr(r,o){return o.endsWith("repeat")?"bg":r.replace("background","bg")}function zr(r){return/(border)|(content)|(padding)-box/.test(r)?r.replace("-box",""):r.startsWith("repeat-")?r.replace("repeat-",""):H(r)}function H(r){return r.replace(/\s+/," ").replace(" ","-")}function C(r,o,t){let n="";if(o&&!t&&(t=o,o=""),r){r=r.replaceAll(N,",");let[e,s]=f(r,"around").replace(/rgba?\(([\w,\s]+)\)/,(m,p)=>m.replace(p,f(p,"all"))).split(" ");s?n+=` from="${x(e)?`[${e}]`:e} ${s}"`:e&&(n+=` from="${x(e)?`[${e}]`:e}"`)}if(o){o=o.replaceAll(N,",");let[e,s]=f(o,"around").replace(/rgba?\(([\w,\s]+)\)/,(m,p)=>m.replace(p,f(p,"all"))).split(" ");s?n+=` via="${x(e)?`[${e}]`:e} ${s}"`:e&&(n+=` via="${x(e)?`[${e}]`:e}"`)}if(t){t=t.replaceAll(N,",");let[e,s]=f(t,"around").replace(/rgba?\(([\w,\s]+)\)/,(m,p)=>m.replace(p,f(p,"all"))).split(" ");s?n+=` to="${x(e)?`[${e}]`:e} ${s}"`:e&&(n+=` to="${x(e)?`[${e}]`:e}"`)}return n}function U(r,o){let[t,n]=i(o),e=r.split("-");return`${e[0]}-${e[1][0]}${a(c(t))}${n}`}function E(r,o){let[t,n]=i(o);if(r==="font-size")return`text-${t}${n}`;if(r==="font-weight")return`font-${t}${n}`;if(r==="font-family"){let e=t.match(/ui-(\w{0,4})/);if(!e)return`font-${o}${n}`;let[s,m]=e;return`font-${m}${n}`}return r==="font-style"?t==="normal"?`font-not-italic${n}`:`font-${t}${n}`:r==="font-variant-numeric"?t==="normal"?`normal-nums${n}`:`${t}${n}`:`font="${Sr(t)}${n}"`}function Sr(r){return r.split(" ").map(o=>/^[0-9]/.test(o)?`text-${o}`:o).join(" ")}function G(r,o){let[t,n]=i(o);return`${r}${a(t)}${n}`}var Tr={"margin-left":"ml","margin-right":"mr","margin-top":"mt","margin-bottom":"mb","margin-inline-start":"ms","margin-inline-end":"me","padding-left":"pl","padding-right":"pr","padding-top":"pt","padding-bottom":"pb","padding-inline-start":"ps","padding-inline-end":"pe"};function P(r,o){let[t,n]=i(o),e=Tr[r];if(e)return`${e}${a(t)}${n}`;let s=f(t).split(" "),m=s.length;return m===1?`${r[0]}${a(s[0])}${n}`:m===2?`${r[0]}x${a(s[1])}${n} ${r[0]}y${a(s[0])}${n}`:m===3?`${r[0]}x${a(s[1])}${n} ${r[0]}t${a(s[0])}${n} ${r[0]}b${a(s[2])}${n}`:`${r[0]}t${a(s[0])}${n} ${r[0]}b${a(s[2])}${n} ${r[0]}l${a(s[3])}${n} ${r[0]}r${a(s[1])}${n}`}function D(r,o){let[t,n]=i(o);return T(o)?`op-${t.replace("%","")}${n}`:`op-${+t*100}${n}`}function Z(r,o){let[t,n]=i(o);return`text${a(t)}${n}`}function q(r,o){let[t,n]=i(o);return r==="text-decoration-line"?t==="none"?`no-underline${n}`:`${t}${n}`:r==="text-transform"?t==="none"?`normal-case${n}`:`${t}${n}`:r.startsWith("text-decoration")||r==="text-indent"?`${r.split("-")[1]}-${t}${n}`:r==="text-underline-offset"?`underline-offset-${t}${n}`:`text-${t}${n}`}function J(r,o){let[t,n]=i(o);return`v-${t}${n}`}function K(r,o){let[t,n]=i(o);return`lh${a(t)}${n}`}var Cr=["border-left","border-top","border-right","border-bottom"];function O(r,o){let[t,n]=i(o);return r==="border-spacing"?`${r}="[${I(t)}]${n}"`:r==="border-color"?`border${a(t)}${n}`:r==="border-radius"?S(t)||!t.includes(" ")?`border-rd${a(t)}${n}`:`border-rd="[${I(t)}]${n}"`:Cr.some(e=>r.startsWith(e))?`border-${r.split("-")[1][0]}${a(t)}${n}`:r==="border-inline-end-width"?`border-e${a(t)}${n}`:r==="border-inline-start-width"?`border-s${a(t)}${n}`:r.startsWith("border-image")?"":/^\d[%|(px)|(rem)]$/.test(t)||r==="border-collapse"?`border-${t}${n}`:r==="border-width"||r==="border-style"?`border${a(t)}${n}`:r==="border-color"?t==="currentColor"?`border-current${n}`:`border${a(t)}${n}`:(/rgb/.test(t)&&(t=t.replace(/rgb[a](.*)/,(e,s)=>e.replace(s,f(s,"all")))),`border="[${I(t)}]${n}"`)}function _(r,o){let[t,n]=i(o);return t==="none"?`hidden${n}`:t==="hidden"?`invisible${n}`:`${t}${n}`}function g(r,o){let[t,n]=i(o);return`${r}-${t}${n}`}function v(r,o){let[t,n]=i(o);return`${r}${a(t)}${n}`}function d(r,o){let[t,n]=i(o);return`${c(r)}${a(t)}${n}`}function F(r,o){let[t,n]=i(o);if(r.startsWith("box-decoration"))return`box-decoration-${t}${n}`;if(r==="box-sizing")return`box-${c(t)}${n}`;let e=/rgba?(\([\w,\s.]+\))/g;return t=t.replace(e,(s,m)=>s.replace(m,f(m,"all"))).replace(/\s*,\s*/g,","),`shadow="[${t.replace(/\s+/," ").split(" ").join("_")}]${n}"`}var Ur=["contrast","brightness","saturate"],Pr=["grayscale","invert","sepia"];function z(r,o){let[t,n]=i(o),[e,s,m]=t.match(/([\w-]+)\((.*)\)/);return Ur.includes(s)?`${s}-${h(m)}${n}`:s==="drop-shadow"?`drop-${F(s,m)}${n}`:Pr.includes(s)?`${s}-${m.endsWith("%")?m.slice(0,-1):h(m)}${n}`:s==="hue-rotate"?`${s}-${m.slice(0,-3)}${n}`:`${s}-${m}${n}`}function Q(r,o){let[t,n]=i(o);return`backdrop-${z(r,t)}${n}`}function Y(r,o){let[t,n]=i(o);return r==="transform-origin"?`origin-${w(t)}${n}`:r==="transform-style"?`transform-${t}`:M(t).split(" ").map(e=>{let s=e.match(/([a-z]+)([A-Z])?\((.*)\)/);if(!s)return;let[m,p,l,$]=s;return l?p==="scale"?$.includes(",")?`${p}-${l.toLowerCase()}="${$.split(",").join(" ")}${n}"`:`${p}-${l.toLowerCase()}-${h($)}${n}`:`${p}-${l.toLowerCase()}="${X($)}${n}"`:p==="scale"?$.includes(",")?`${p}="${$.split(",").join(" ")}${n}"`:`${p}-${h($)}${n}`:`${p}="${X($).replace(/,/g," ")}${n}"`}).filter(Boolean).join(" ")}function X(r){return r=f(r,"all"),r.endsWith("deg")?r.slice(0,-3):r}var Rr=["transition-delay","transition-duration"];function y(r,o){let[t,n]=i(o);if(r==="transition-timing-function")return t==="linear"?`ease-${t}${n}`:`ease="[${f(t,"all")}]${n}"`;if(r==="transition")return`transition="${Ar(t)}"`;if(r==="transition-property")return t.includes("color")?`transition-color${n}`:t==="box-shadow"?`transition-shadow${n}`:`transition-${t}${n}`;if(Rr.includes(r))return`${r.split("-")[1]}-${t.slice(0,-2)}`}function Ar(r){let o=!1;return r.split(" ").map(t=>/^[0-9]/.test(t)||/^\.[0-9]/.test(t)?o?`delay${a(t,void 0,!0)}`:(o=!0,`duration${a(t,void 0,!0)}`):t==="background-color"?"colors":t).join(" ")}function k(r,o){let[t,n]=i(o);return r==="justify-content"?`justify-${u(t)}${n}`:`${r}-${u(t)}${n}`}function rr(r,o){let[t,n]=i(o);return`${u(r)}-${u(t)}${n}`}var Mr=["flex-basis","flex-grow","flex-shrink"];function tr(r,o){let[t,n]=i(o);if(Mr.includes(r))return`${u(r)}-${t}${n}`;if(t==="1")return`flex-1${n}`;let e=f(t)[0];return r==="flex"&&(e==="0"||e==="1")?`flex="[${I(t)}]${n}"`:`${c(r)}-${t.replace("column","col")}${n}`}function nr(r,o){let[t,n]=i(o);return t==="auto"?`${c(r)}-${t}`:`${c(r)}="[${f(t,"all")}]${n}"`}function or(r,o){let[t,n]=i(o);return r==="column-gap"?`gap-x-${t}${n}`:`${r}-${t}${n}`}function ir(r,o){let[t,n]=i(o);return o==="isolate"?`${t}${n}`:`${r}-${t}${n}`}function er(r,o){let[t,n]=i(o);return r==="object-position"?`${c(r)}-${w(t)}${n}`:`${c(r)}-${t}${n}`}function sr(r,o){let[t,n]=i(o),[e,s,m]=r.split("-");return m?`${e}-${m}-${t}${n}`:`${e}-${t}${n}`}function ar(r,o){let[t,n]=i(o);if(r.startsWith("grid-template")){let s=t.match(/repeat\s*\(\s*([0-9]+)/);return s?`grid-${u(r)==="rows"?"rows":"cols"}-${s[1]}${n}`:`grid-${u(r)==="rows"?"rows":"cols"}-${t}${n}`}if(r==="grid-auto-flow")return`grid-flow-${w(t).replace("column","col")}${n}`;if(r.startsWith("grid-auto")){let s=t.match(/minmax\s*\(\s*0\s*,\s*1fr/);return`auto-${u(r)==="rows"?"rows":"cols"}-${s?"fr":c(t)}${n}`}let e=t.match(/span\s+([0-9])/);return e?`${r.slice(5).replace("column","col")}-span-${e[1]}${n}`:f(t,"all")==="1/-1"?`${r.slice(5).replace("column","col")}-span-full${n}`:`${r.slice(5).replace("column","col")}-${t}${n}`}function mr(r,o){let[t,n]=i(o);return`gap-y-${t}${n}`}function pr(r,o){let[t,n]=i(o);return`${r}-${u(t)}${n}`}function fr(r,o){let[t,n]=i(o);return`tracking-${t}${n}`}function cr(r,o){let[t,n]=i(o);return`whitespace-${t}${n}`}function ur(r,o){let[t,n]=i(o);return r.startsWith("word-spacing")?`word-spacing${a(o)}`:t==="keep-all"?`break-keep${n}`:`break-${u(t)}${n}`}function lr(r,o){let[t,n]=i(o);return r==="outline-offset"?`${r}-${t}${n}`:`${c(r)}-${t}${n}`}function $r(r,o){let[t,n]=i(o);return`mix-blend-${t}${n}`}var Br={vertical:"y",horizontal:"x"};function gr(r,o){let[t,n]=i(o);return t==="both"?`${r}${n}`:`${r}-${Br[t]||t}${n}`}function dr(r,o){let[t,n]=i(o);if(r.startsWith("scroll-snap"))return`snap-${t}${n}`;if(r==="scroll-behavior")return`scroll-${t}${n}`;let[e,s,m,p]=r.match(/scroll-(margin|padding)-?([\w]+)?-?([\w]+)?/);return m==="inline"&&p?`scroll-${s[0]}${p[0]}-${t}${n}`:m?`scroll-${s[0]}${m[0]}-${t}${n}`:`scroll-${s[0]}-${t}${n}`}function xr(r,o){let[t,n]=i(o);return`${u(r)}-${t}${n}`}function br(r,o){let[t,n]=i(o);return`${r}-${c(t)}${n}`}function hr(r,o){let[t,n]=i(o);return r==="animation-delay"?`animate${a(t)}${n}`:r==="animation"?`animate-${t.split(" ")[0]}${n}`:`animate-${t}${n}`}function wr(r,o){let[t,n]=i(o);return`content="[${t}]${n}"`}var Hr={show:"visible",hide:"hidden"};function Ir(r,o){var e;let[t,n]=i(o);return`table-empty-cells-${(e=Hr[t])!=null?e:t}${n}`}function vr(r,o){return o==="horizontal-tb"?"write-normal":`write-${o.replace("-rl","-right").replace("-lr","-left")}`}function jr(r,o){let[t,n]=i(o);if(r==="inset-inline-start")return`start${a(t)}${n}`;if(r==="inset-inline-end")return`end${a(t)}${n}`}var R={animation:hr,aspect:nr,backface:d,caption:d,column:or,columns:g,break:g,empty:Ir,box:F,writing:vr,display:_,float:g,clear:g,isolation:ir,object:er,overflow:g,overscroll:sr,position:_,top:v,left:v,right:v,bottom:v,visibility:_,z:L,flex:tr,order:g,grid:ar,gap:v,justify:k,align:rr,place:pr,padding:P,perspective:g,margin:P,width:L,min:U,max:U,height:L,font:E,letter:fr,line:K,list:d,text:q,vertical:J,white:cr,word:ur,content:wr,background:B,border:O,outline:lr,opacity:D,mix:$r,filter:z,backdrop:Q,table:d,transition:y,transform:Y,accent:d,appearance:d,cursor:G,caret:d,pointer:g,resize:gr,scroll:dr,inset:jr,touch:d,user:xr,will:br,fill:g,stroke:d,color:Z,row:mr},Er=/([\w-]+)\s*:\s*([.\w\(\)-\s%+'",#\/!]+)/;function A(r,o=!1){var l;let t=r.match(Er);if(!t)return;let[n,e,s]=t,m=c(e),p=(l=R[m])==null?void 0:l.call(R,e,s);return p&&o?p.replace(/-([0-9\.]+)px/,($,b)=>`-${+b/4}`):p}function Gr(r,o){let t=[];return[r.split(";").filter(Boolean).reduce((n,e)=>{let s=A(e,o)||"";return s||t.push(e),n+=`${s} `},"").trim(),t]}export{A as toUnocss,Gr as transformStyleToUnocss};
|
package/license
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Simon He
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "transform-to-unocss-core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"packageManager": "pnpm@7.2.1",
|
|
5
|
+
"description": "",
|
|
6
|
+
"author": "Simon He",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"funding": "https://github.com/sponsors/Simon-He95",
|
|
9
|
+
"homepage": "https://github.com/Simon-He95/transform-to-unocss-core#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Simon-He95/transform-to-unocss-core.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": "https://github.com/Simon-He95/transform-to-unocss-core/issues",
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"require": "./dist/index.js",
|
|
21
|
+
"import": "./dist/index.mjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"typesVersions": {
|
|
28
|
+
"*": {
|
|
29
|
+
"*": [
|
|
30
|
+
"./dist/*",
|
|
31
|
+
"./dist/index.d.ts"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"run": "./cli.mjs"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup ./src/index.ts --format cjs,esm --dts --clean --minify",
|
|
43
|
+
"dev": "npm run build -- --watch src",
|
|
44
|
+
"format": "prettier --write --cache .",
|
|
45
|
+
"lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx,.md,.json --max-warnings 0 --cache",
|
|
46
|
+
"lint:fix": "pnpm run lint --fix",
|
|
47
|
+
"prepublishOnly": "nr build",
|
|
48
|
+
"release": "bumpp && npm publish",
|
|
49
|
+
"start": "esno src/index.ts",
|
|
50
|
+
"test": "vitest",
|
|
51
|
+
"typecheck": "tsc --noEmit"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@antfu/eslint-config": "^0.25.1",
|
|
55
|
+
"@types/node": "^18.0.0",
|
|
56
|
+
"bumpp": "^8.2.1",
|
|
57
|
+
"eslint": "^8.18.0",
|
|
58
|
+
"esno": "^0.16.3",
|
|
59
|
+
"prettier": "^2.8.1",
|
|
60
|
+
"rimraf": "^3.0.2",
|
|
61
|
+
"tsup": "^6.5.0",
|
|
62
|
+
"tsx": "^3.12.1",
|
|
63
|
+
"typescript": "^4.7.4",
|
|
64
|
+
"vitest": "^0.15.1"
|
|
65
|
+
},
|
|
66
|
+
"eslintConfig": {
|
|
67
|
+
"extends": "@antfu"
|
|
68
|
+
}
|
|
69
|
+
}
|