@projectwallace/format-css 1.5.4 → 2.0.0-alpha.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/package.json +5 -6
- package/dist/format-css.umd.cjs +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectwallace/format-css",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "Fast, small, zero-config library to format CSS with basic rules.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,17 +9,16 @@
|
|
|
9
9
|
"homepage": "https://github.com/projectwallace/format-css",
|
|
10
10
|
"issues": "https://github.com/projectwallace/format-css/issues",
|
|
11
11
|
"license": "MIT",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.0.0"
|
|
14
|
+
},
|
|
12
15
|
"type": "module",
|
|
13
|
-
"
|
|
16
|
+
"main": "./dist/format-css.js",
|
|
14
17
|
"exports": {
|
|
15
18
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"require": "./dist/format-css.umd.cjs",
|
|
17
19
|
"default": "./dist/format-css.js"
|
|
18
20
|
},
|
|
19
21
|
"types": "./dist/index.d.ts",
|
|
20
|
-
"main": "./dist/format-css.umd.cjs",
|
|
21
|
-
"module": "./dist/format-css.js",
|
|
22
|
-
"unpkg": "./dist/format-css.umd.cjs",
|
|
23
22
|
"scripts": {
|
|
24
23
|
"build": "vite build",
|
|
25
24
|
"test": "c8 --reporter=lcov uvu",
|
package/dist/format-css.umd.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(_,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("css-tree/parser")):typeof define=="function"&&define.amd?define(["exports","css-tree/parser"],S):(_=typeof globalThis<"u"?globalThis:_||self,S(_.formatCss={},_.parse))})(this,function(_,S){"use strict";const i=" ",o="",k=":",N=";",A='"',x="(",L=")",Q="[",J="]",K="{",U="}",X="{}",D=",",j="Atrule",H="Rule",V="Block",W="SelectorList",I="Selector",Y="Declaration",B="Operator";function b(y){return/[A-Z]/.test(y)?y.toLowerCase():y}function Z(y,{minify:P=!1}={}){let g=[],M=S(y,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0,onComment:(n,e)=>{g.push(e.start.offset,e.end.offset)}});const u=P?o:`
|
|
2
|
-
`,T=P?o:i,ee=P?o:N;let s=0;function a(n){return P?o:" ".repeat(n)}function O(n){let e=n.loc;return e?y.slice(e.start.offset,e.end.offset):o}function C(n){return n.loc.start.offset}function c(n){return n.loc.end.offset}function E(n,e){if(P||n===void 0||e===void 0)return o;let t="";for(let r=0;r<g.length;r+=2){let l=g[r];if(l===void 0||l<n)continue;let f=g[r+1];if(f===void 0||f>e)break;t.length>0&&(t+=u+a(s)),t+=y.slice(l,f)}return t}function h(n){let e,t=n.prelude,r=n.block;t.type===W&&(e=te(t));let l=E(c(t),C(r));return l&&(e+=u+a(s)+l),r.type===V&&(e+=q(r)),e}function te(n){let e=o;return n.children.forEach((t,r)=>{t.type===I&&(e+=a(s)+v(t)),r.next!==null&&(e+=D+u);let l=r.next!==null?C(r.next.data):c(n),f=E(c(t),l);f&&(e+=a(s)+f+u)}),e}function v(n){let e=o;return(n.children||[]).forEach(r=>{switch(r.type){case"TypeSelector":{e+=b(r.name);break}case"Combinator":{e+=i,r.name!==" "&&(e+=r.name+i);break}case"PseudoClassSelector":case"PseudoElementSelector":{e+=k;let l=b(r.name);(l==="before"||l==="after"||r.type==="PseudoElementSelector")&&(e+=k),e+=l,r.children&&(e+=x+v(r)+L);break}case W:{r.children.forEach((l,f)=>{l.type===I&&(e+=v(l)),f.next&&f.next.data.type===I&&(e+=D+T)});break}case"Nth":{let l=r.nth;if(l)if(l.type==="AnPlusB"){let f=l.a,p=l.b;f!==null&&(e+=f+"n"),f!==null&&p!==null&&(e+=i),p!==null&&(f!==null&&!p.startsWith("-")&&(e+="+"+i),e+=p)}else e+=O(l);r.selector!==null&&(e+=i+"of"+i+v(r.selector));break}case"AttributeSelector":{e+=Q,e+=r.name.name,r.matcher&&r.value&&(e+=r.matcher,e+=A,r.value.type==="String"?e+=r.value.value:r.value.type==="Identifier"&&(e+=r.value.name),e+=A),r.flags&&(e+=i+r.flags),e+=J;break}default:{e+=O(r);break}}}),e}function q(n){let e=n.children,t=T;if(e.isEmpty){let f=E(C(n),c(n));return f?(t+=K+u,t+=a(s+1)+f,t+=u+a(s)+U,t):t+X}t+=K+u,s++;let r=E(C(n),C(e.first));r&&(t+=a(s)+r+u),e.forEach((f,p)=>{if(p.prev!==null){let G=E(c(p.prev.data),C(f));G&&(t+=a(s)+G+u)}f.type===Y?(t+=ne(f),p.next===null?t+=ee:t+=N):(p.prev!==null&&p.prev.data.type===Y&&(t+=u),f.type===H?t+=h(f):f.type===j?t+=z(f):t+=w(f,s)),p.next!==null&&(t+=u,f.type!==Y&&(t+=u))});let l=E(c(e.last),c(n));return l&&(t+=u+a(s)+l),s--,t+=u+a(s)+U,t}function z(n){let e=a(s)+"@",t=n.prelude,r=n.block;return e+=b(n.name),t!==null&&(e+=i+re(t)),r===null?e+=N:r.type===V&&(e+=q(r)),e}function re(n){let e=O(n);return e.replace(/\s*([:,])/g,e.toLowerCase().includes("selector(")?"$1":"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/\)([a-zA-Z])/g,") $1").replace(new RegExp("(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])","g")," $1 ").replace(/calc\(([^*]*)\*([^*])/g,"calc($1 * $2").replace(/\s+/g,i).replace(/selector|url|supports|layer\(/ig,t=>b(t))}function ne(n){let e=n.property;e.charCodeAt(0)===45&&e.charCodeAt(1)===45||(e=b(e));let t=F(n.value);return e==="font"&&(t=t.replace(/\s*\/\s*/,"/")),t===o&&P&&(t+=i),n.important===!0?t+=T+"!important":typeof n.important=="string"&&(t+=T+"!"+b(n.important)),a(s)+e+k+T+t}function $(n){let e=o;return n.forEach((t,r)=>{t.type==="Identifier"?e+=t.name:t.type==="Function"?e+=b(t.name)+x+$(t.children)+L:t.type==="Dimension"?e+=t.value+b(t.unit):t.type==="Value"?e+=F(t):t.type===B?e+=le(t):t.type==="Parentheses"?e+=x+$(t.children)+L:t.type==="Url"?e+="url("+A+t.value+A+L:e+=O(t),t.type!==B&&r.next!==null&&r.next.data.type!==B&&(e+=i)}),e}function le(n){let e=o,t=n.value.trim(),r=t.charCodeAt(0);return r===43||r===45?e+=i:r!==44&&(e+=T),e+=t,r===43||r===45?e+=i:e+=T,e}function F(n){return n.type==="Raw"?w(n,0):$(n.children)}function w(n,e){return a(e)+O(n).trim()}let R=M.children,m=o;if(R.first){let n=E(0,C(R.first));n&&(m+=n+u),R.forEach((t,r)=>{if(t.type===H?m+=h(t):t.type===j?m+=z(t):m+=w(t,s),r.next!==null){m+=u;let l=E(c(t),C(r.next.data));l&&(m+=a(s)+l),m+=u}});let e=E(c(R.last),c(M));e&&(m+=u+e)}else m+=E(0,c(M));return m}function d(y){return Z(y,{minify:!0})}_.format=Z,_.minify=d,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|