@projectwallace/format-css 1.2.0 → 1.3.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 CHANGED
@@ -4,7 +4,33 @@ Fast, small, zero-config library to format CSS with basic [rules](#formatting-ru
4
4
 
5
5
  ## Example output
6
6
 
7
- ![Example input-output of this formatter](https://github.com/projectwallace/format-css/assets/1536852/ce160fd3-fa11-4d90-9432-22567ee1d851)
7
+ <!-- prettier-ignore -->
8
+ ```css
9
+ /* TURN THIS: */
10
+
11
+ @layer base.normalize{@media (dynamic-range:high) or (color-gamut:p3){@supports (color:color(display-p3 0 0 0)){:where(html){--link:color(display-p3 .1 .4 1);--link-visited:color(display-p3 .6 .2 1)}}}}@layer base.normalize{:where(html) :where(dialog){background-color:var(--surface-1)}}
12
+
13
+ /* INTO THIS: */
14
+
15
+ @layer base.normalize {
16
+ @media (dynamic-range: high) or (color-gamut: p3) {
17
+ @supports (color: color(display-p3 0 0 0)) {
18
+ :where(html) {
19
+ --link: color(display-p3 .1 .4 1);
20
+ --link-visited: color(display-p3 .6 .2 1);
21
+ }
22
+ }
23
+ }
24
+ }
25
+
26
+ @layer base.normalize {
27
+ :where(html) :where(dialog) {
28
+ background-color: var(--surface-1);
29
+ }
30
+ }
31
+
32
+ /* AND BACK AGAIN! */
33
+ ```
8
34
 
9
35
  ## Installation
10
36
 
@@ -59,6 +85,6 @@ let formatted_mini = format("a {}", { minify: true });
59
85
 
60
86
  ## Related projects
61
87
 
62
- - [Format CSS online](https://www.projectwallace.com/prettify-css?utm_source=github&utm_medium=wallace_format_css_related_projects) - See this minifier in action online!
88
+ - [Format CSS online](https://www.projectwallace.com/prettify-css?utm_source=github&utm_medium=wallace_format_css_related_projects) - See this formatter in action online!
89
+ - [Minify CSS online](https://www.projectwallace.com/minify-css?utm_source=github&utm_medium=wallace_format_css_related_projects) - See this minifier in action online!
63
90
  - [CSS Analyzer](https://github.com/projectwallace/css-analyzer) - The best CSS analyzer that powers all analysis on [projectwallace.com](https://www.projectwallace.com?utm_source=github&utm_medium=wallace_format_css_related_projects)
64
- - [Minify CSS](https://github.com/projectwallace/minify-css) The exact opposite of this library: fast, small, zero-config CSS minifier.
package/dist/format.cjs CHANGED
@@ -1,2 +1,2 @@
1
- function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/e(require("css-tree/parser"));function t(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function n(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a="\n",o="\t",l=" ";function u(e){return o.repeat(e)}function i(e,r){var t=e.loc;if(!t)return"";var n=t.start,a=t.end,o=r.substring(n.offset,a.offset);return n.line===a.line?o:o.replace(/\s+/g," ")}function c(e,r,t){var o,l=e.prelude,u=e.block;return o=void 0!==l&&"SelectorList"===l.type?function(e,r,t){for(var o,l="",u=e.children,i=n(u);!(o=i()).done;){var c=o.value;l+="Selector"===c.type?f(c,r,t):g(c,r,t),c!==u.last&&(l+=","+a)}return l}(l,r,t):g(l,r,t),null!==u&&"Block"===u.type&&(o+=p(u,r,t)),o}function s(e,r){var t="";if(e.children)for(var a,o=n(e.children);!(a=o()).done;){var l=a.value;switch(l.type){case"Combinator":t+=" "," "!==l.name&&(t+=l.name+" ");break;case"PseudoClassSelector":t+=":"+l.name,l.children&&(t+="("+s(l,r)+")");break;case"SelectorList":for(var u,c=n(l.children);!(u=c()).done;){var f=u.value;"Selector"===f.type&&(t+=s(f,r)),f!==l.children.last&&(t+=", ")}break;case"Nth":if(l.nth)if("AnPlusB"===l.nth.type){var p=l.nth.a,v=l.nth.b;null!==p&&(t+=p+"n"),null!==p&&null!==v&&(t+=" "),null!==v&&(null===p||v.startsWith("-")||(t+="+ "),t+=v)}else t+=i(l.nth,r);null!==l.selector&&(t+=" of "+s(l.selector,r));break;default:t+=i(l,r)}}return t}function f(e,r,t){return u(t)+s(e,r)}function p(e,r,t){var o,i=e.children,s=l;if(i.isEmpty)return s+"{}";s+="{"+a,t++;for(var f,p=n(i);!(f=p()).done;){var d=f.value;"Declaration"===d.type?s+=y(d,r,t)+";":("Declaration"===o&&(s+=a),s+="Rule"===d.type?c(d,r,t):"Atrule"===d.type?v(d,r,t):g(d,r,t)),d!==i.last&&(s+=a,"Declaration"!==d.type&&(s+=a)),o=d.type}return t--,(s+=a)+(u(t)+"}")}function v(e,r,t){var n=u(t)+"@"+e.name.toLowerCase(),a=e.prelude,o=e.block;return null!==a&&(n+=" "+function(e,r){return i(e,r).replace(/\s*([:,])/g,"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g," ")}(a,r)),null===o?n+=";":"Block"===o.type&&(n+=p(o,r,t)),n}function y(e,r,t){var n=e.property;!n.startsWith("--")&&/[A-Z]/.test(n)&&(n=n.toLowerCase());var a=h(e.value,r).trim();return"font"===n&&(a=a.replace(/\s*\/\s*/,"/")),u(t)+n+":"+l+a}function d(e,r){for(var t,a="",o=n(e);!(t=o()).done;){var l=t.value;l!==e.first&&"Operator"!==l.type&&(a+=" "),"Identifier"===l.type?a+=l.name:"Function"===l.type?a+=b(l,r):"Dimension"===l.type?a+=m(l):"Value"===l.type?a+=h(l,r):"Operator"===l.type?(","!==l.value&&(a+=" "),a+=i(l,r)):a+=i(l,r)}return a}function m(e){return e.value+e.unit.toLowerCase()}function h(e,r){return"Raw"===e.type?g(e,r,0):d(e.children,r)}function b(e,r){var t=e.name,n=t;return/[A-Z]/.test(t)&&(n=t.toLowerCase()),n+="(",(n+=d(e.children,r))+")"}function g(e,r,t){return u(t)+function(e,r){var t=e.loc;return t?r.substring(t.start.offset,t.end.offset):""}(e,r).trim()}function A(e,t){var u=(void 0===t?{}:t).minify,i=void 0!==u&&u,s=r.default(e,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return o=i?"":"\t",a=i?"":"\n",l=i?"":" ",function(e,r,t){void 0===t&&(t=0);for(var o,l="",u=e.children,i=n(u);!(o=i()).done;){var s=o.value;l+="Rule"===s.type?c(s,r,t):"Atrule"===s.type?v(s,r,t):g(s,r,t),s!==u.last&&(l+=a+a)}return l}(s,e,0)}exports.format=A,exports.minify=function(e){return A(e,{minify:!0})};
1
+ function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=/*#__PURE__*/e(require("css-tree/parser")),n=" ",r="",u="Atrule",a="Rule",o="Block",l="SelectorList",i="Selector",c="Declaration",f="Operator",s="\n",p="\t",d=" ",y=";";function v(e){return p.repeat(e)}function h(e){return/[A-Z]/.test(e)}function m(e,t){var u=e.loc;if(!u)return r;var a=u.start,o=u.end,l=t.substring(a.offset,o.offset);return a.line===o.line?l:l.replace(/\s+/g,n)}function b(e,t,n){var u,a=e.prelude,c=e.block;return u=a.type===l?function(e,t,n){var u=r;return e.children.forEach(function(e,r){u+=e.type===i?function(e,t,n){return v(n)+C(e,t)}(e,t,n):E(e,t,n),null!==r.next&&(u+=","+s)}),u}(a,t,n):E(a,t,n),c.type===o&&(u+=x(c,t,n)),u}function C(e,t){var u=r;return e.children?(e.children.forEach(function(e){switch(e.type){case"Combinator":u+=n," "!==e.name&&(u+=e.name+n);break;case"PseudoClassSelector":u+=":","before"!==e.name&&"after"!==e.name||(u+=":"),u+=e.name,e.children&&(u+="("+C(e,t)+")");break;case l:e.children.forEach(function(e,r){e.type===i&&(u+=C(e,t)),r.next&&(u+=","+n)});break;case"Nth":var r=e.nth;if(r)if("AnPlusB"===r.type){var a=r.a,o=r.b;null!==a&&(u+=a+"n"),null!==a&&null!==o&&(u+=n),null!==o&&(null===a||o.startsWith("-")||(u+="+"+n),u+=o)}else u+=m(e.nth,t);null!==e.selector&&(u+=n+"of"+n+C(e.selector,t));break;default:u+=m(e,t)}}),u):u}function x(e,t,n){var r=e.children,o=d;return r.isEmpty?o+"{}":(o+="{"+s,n++,r.forEach(function(e,r){e.type===c?(o+=function(e,t,n){var r=e.property;45===r.charCodeAt(0)&&45===r.charCodeAt(1)||h(r)&&(r=r.toLowerCase());var u=A(e.value,t);return"font"===r&&(u=u.replace(/\s*\/\s*/,"/")),v(n)+r+":"+d+u}(e,t,n),o+=null===r.next?y:";"):(null!==r.prev&&r.prev.data.type===c&&(o+=s),o+=e.type===a?b(e,t,n):e.type===u?g(e,t,n):E(e,t,n)),null!==r.next&&(o+=s,e.type!==c&&(o+=s))}),n--,o+=s,o+=v(n)+"}")}function g(e,t,r){var u=v(r)+"@",a=e.name,l=e.prelude,i=e.block;return u+=h(a)?a.toLowerCase():a,null!==l&&(u+=n+function(e,t){var r=m(e,t);return r.replace(/\s*([:,])/g,r.includes("selector(")?"$1":"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g,n)}(l,t)),null===i?u+=";":i.type===o&&(u+=x(i,t,r)),u}function k(e,t){var u=r;return e.forEach(function(e,r){if("Identifier"===e.type)u+=e.name;else if("Function"===e.type)u+=function(e,t){var n=e.name,r=n;return h(n)&&(r=n.toLowerCase()),r+="(",(r+=k(e.children,t))+")"}(e,t);else if("Dimension"===e.type)u+=function(e){var t=e.unit;return e.value+(h(t)?t.toLowerCase():t)}(e);else if("Value"===e.type)u+=A(e,t);else if(e.type===f){var a=e.value.trim(),o=a.charCodeAt(0);43===o||45===o?u+=n:44!==o&&(u+=d),u+=a,u+=43===o||45===o?n:d}else u+=m(e,t);e.type!==f&&null!==r.next&&r.next.data.type!==f&&(u+=n)}),u}function A(e,t){return"Raw"===e.type?E(e,t,0):k(e.children,t)}function E(e,t,n){return v(n)+function(e,t){var n=e.loc;return n?t.substring(n.start.offset,n.end.offset):r}(e,t).trim()}function w(e,n){var o=(void 0===n?{}:n).minify,l=void 0!==o&&o,i=t.default(e,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return p=l?r:"\t",s=l?r:"\n",d=l?r:" ",y=l?r:";",function(e,t,n){void 0===n&&(n=0);var o=r;return e.children.forEach(function(e,r){o+=e.type===a?b(e,t,n):e.type===u?g(e,t,n):E(e,t,n),null!==r.next&&(o+=s+s)}),o}(i,e,0)}exports.format=w,exports.minify=function(e){return w(e,{minify:!0})};
2
2
  //# sourceMappingURL=format.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.cjs","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet SPACE = ' ' // or ''\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return ''\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, ' ')\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return ''\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude !== undefined && prelude.type === 'SelectorList') {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block !== null && block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = ''\n\tlet children = node.children\n\n\tfor (let selector of children) {\n\t\tif (selector.type === 'Selector') {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (selector !== children.last) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = ''\n\n\tif (node.children) {\n\t\tfor (let child of node.children) {\n\t\t\tswitch (child.type) {\n\t\t\t\tcase 'Combinator': {\n\t\t\t\t\t// putting spaces around `child.name`, unless the combinator is ' '\n\t\t\t\t\tbuffer += ' '\n\t\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\t\tbuffer += child.name + ' '\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\t\tbuffer += ':' + child.name\n\n\t\t\t\t\tif (child.children) {\n\t\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'SelectorList': {\n\t\t\t\t\tfor (let grandchild of child.children) {\n\t\t\t\t\t\tif (grandchild.type === 'Selector') {\n\t\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (grandchild !== child.children.last) {\n\t\t\t\t\t\t\tbuffer += ', '\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'Nth': {\n\t\t\t\t\tif (child.nth) {\n\t\t\t\t\t\tif (child.nth.type === 'AnPlusB') {\n\t\t\t\t\t\t\tlet a = child.nth.a\n\t\t\t\t\t\t\tlet b = child.nth.b\n\n\t\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\t\tbuffer += ' '\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\t\tbuffer += '+ '\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t\t// `of .selector`\n\t\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\t\tbuffer += ' of ' + print_simple_selector(child.selector, css)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbuffer += substr(child, css)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tlet prev_type\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Declaration') {\n\t\t\tbuffer += print_declaration(child, css, indent_level) + ';'\n\t\t} else {\n\t\t\tif (prev_type === 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === 'Rule') {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === 'Atrule') {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\n\t\tprev_type = child.type\n\t}\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@' + node.name.toLowerCase()\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += ' ' + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, '$1 ') // force whitespace after colon or comma\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, ' ') // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\tif (!property.startsWith('--') && /[A-Z]/.test(property)) {\n\t\tproperty = property.toLowerCase()\n\t}\n\n\tlet value = print_value(node.value, css).trim()\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = ''\n\n\tfor (let node of children) {\n\t\tif (node !== children.first && node.type !== 'Operator') {\n\t\t\tbuffer += ' '\n\t\t}\n\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === 'Operator') {\n\t\t\t// Put extra spacing before + - / *\n\t\t\t// but not before a comma\n\t\t\tif (node.value !== ',') {\n\t\t\t\tbuffer += ' '\n\t\t\t}\n\t\t\tbuffer += substr(node, css)\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Dimension} node\n */\nfunction print_dimension(node) {\n\treturn node.value + node.unit.toLowerCase()\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (/[A-Z]/.test(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {number} indent_level\n * @param {string} css\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = ''\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Rule') {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === 'Atrule') {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? '' : '\\t'\n\tNEWLINE = minify ? '' : '\\n'\n\tSPACE = minify ? '' : ' '\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["NEWLINE","TAB","SPACE","indent","size","repeat","substr","node","css","loc","start","end","str","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","undefined","type","_step","children","_iterator","_createForOfIteratorHelperLoose","done","selector","value","print_selector","print_unknown","last","print_selectorlist","print_block","print_simple_selector","_step2","_iterator2","child","name","_iterator3","_step3","grandchild","nth","a","b","startsWith","prev_type","isEmpty","_step4","_iterator4","print_declaration","print_atrule","toLowerCase","print_prelude","property","test","print_value","trim","print_list","_step5","_iterator5","first","print_function","print_dimension","unit","substr_raw","format","_temp","_ref","_ref$minify","minify","ast","parse","positions","parseAtrulePrelude","parseCustomProperty","parseValue","_step6","_iterator6","print"],"mappings":"+6B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Y,IAOb,OAJA7E,EAAMuE,EAAS,GAAK,KACpBxE,EAAUwE,EAAS,GAAK,KACxBtE,EAAQsE,EAAS,GAAK,IAzCvB,SAAejE,EAAMC,EAAKU,QAAAA,IAAAA,IAAAA,EAAe,GAKxC,IAJA,IAI0B6D,EAJtB5D,EAAS,GAETM,EAAWlB,EAAKkB,SAEpBuD,EAAArD,EAAkBF,KAAQsD,EAAAC,KAAApD,MAAE,CAAnB,IAAAW,EAAKwC,EAAAjD,MAEZX,GADkB,SAAfoB,EAAMhB,KACCN,EAAWsB,EAAO/B,EAAKU,GACR,WAAfqB,EAAMhB,KACN8B,EAAad,EAAO/B,EAAKU,GAEzBc,EAAcO,EAAO/B,EAAKU,GAGjCqB,IAAUd,EAASQ,OACtBd,GAAUnB,EAAUA,EAEtB,CAEA,OAAOmB,CACR,CAuBQ8D,CAAMR,EAAKjE,EAAK,EACxB,iCAOgB,SAAOA,GACtB,OAAO4D,EAAO5D,EAAK,CAAEgE,QAAQ,GAC9B"}
1
+ {"version":3,"file":"format.cjs","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\nconst SPACE = ' '\nconst EMPTY_STRING = ''\nconst TYPE_ATRULE = 'Atrule'\nconst TYPE_RULE = 'Rule'\nconst TYPE_BLOCK = 'Block'\nconst TYPE_SELECTORLIST = 'SelectorList'\nconst TYPE_SELECTOR = 'Selector'\nconst TYPE_DECLARATION = 'Declaration'\nconst TYPE_OPERATOR = 'Operator'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet OPTIONAL_SPACE = ' ' // or ''\nlet LAST_SEMICOLON = ';'\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * Check if a string contains uppercase characters\n * @param {string} str\n */\nfunction is_uppercase(str) {\n\treturn /[A-Z]/.test(str)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return EMPTY_STRING\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, SPACE)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return EMPTY_STRING\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude.type === TYPE_SELECTORLIST) {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\t// In case parsing the selector list fails we'll print it as-is\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = EMPTY_STRING\n\tlet children = node.children\n\n\tchildren.forEach((selector, item) => {\n\t\tif (selector.type === TYPE_SELECTOR) {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = EMPTY_STRING\n\n\tif (!node.children) {\n\t\treturn buffer\n\t}\n\n\tnode.children.forEach((child) => {\n\t\tswitch (child.type) {\n\t\t\tcase 'Combinator': {\n\t\t\t\t// putting spaces around `child.name` (+ > ~ or ' '), unless the combinator is ' '\n\t\t\t\tbuffer += SPACE\n\n\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\tbuffer += child.name + SPACE\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\tbuffer += ':'\n\n\t\t\t\t// Special case for `:before` and `:after` which were used in CSS2 and are usually minified\n\t\t\t\t// as `:before` and `:after`, but we want to keep them as `::before` and `::after`\n\t\t\t\tif (child.name === 'before' || child.name === 'after') {\n\t\t\t\t\tbuffer += ':'\n\t\t\t\t}\n\n\t\t\t\tbuffer += child.name\n\n\t\t\t\tif (child.children) {\n\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase TYPE_SELECTORLIST: {\n\t\t\t\tchild.children.forEach((grandchild, item) => {\n\t\t\t\t\tif (grandchild.type === TYPE_SELECTOR) {\n\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t}\n\n\t\t\t\t\tif (item.next) {\n\t\t\t\t\t\tbuffer += ',' + SPACE\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Nth': {\n\t\t\t\tlet nth = child.nth\n\t\t\t\tif (nth) {\n\t\t\t\t\tif (nth.type === 'AnPlusB') {\n\t\t\t\t\t\tlet a = nth.a\n\t\t\t\t\t\tlet b = nth.b\n\n\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\tbuffer += SPACE\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\tbuffer += '+' + SPACE\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t// `of .selector`\n\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\tbuffer += SPACE + 'of' + SPACE + print_simple_selector(child.selector, css)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbuffer += substr(child, css)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = OPTIONAL_SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_DECLARATION) {\n\t\t\tbuffer += print_declaration(child, css, indent_level)\n\n\t\t\tif (item.next === null) {\n\t\t\t\tbuffer += LAST_SEMICOLON\n\t\t\t} else {\n\t\t\t\tbuffer += ';'\n\t\t\t}\n\t\t} else {\n\t\t\tif (item.prev !== null && item.prev.data.type === TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === TYPE_RULE) {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\t})\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@'\n\tlet name = node.name\n\tlet prelude = node.prelude\n\tlet block = node.block\n\tbuffer += is_uppercase(name) ? name.toLowerCase() : name\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += SPACE + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, buffer.includes('selector(') ? '$1' : '$1 ') // force whitespace after colon or comma, except inside `selector()`\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, SPACE) // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\t// Lowercase the property, unless it's a custom property (starts with --)\n\tif (!(property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45)) { // 45 == '-'\n\t\tif (is_uppercase(property)) {\n\t\t\tproperty = property.toLowerCase()\n\t\t}\n\t}\n\n\tlet value = print_value(node.value, css)\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + OPTIONAL_SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = EMPTY_STRING\n\n\tchildren.forEach((node, item) => {\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === TYPE_OPERATOR) {\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/CSS/calc#notes\n\t\t\t// The + and - operators must be surrounded by whitespace\n\t\t\t// Whitespace around other operators is optional\n\n\t\t\t// Trim the operator because CSSTree adds whitespace around it\n\t\t\tlet operator = node.value.trim()\n\t\t\tlet code = operator.charCodeAt(0)\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space before + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else if (code !== 44) { // ,\n\t\t\t\t// Add optional space before operator\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\n\t\t\t// FINALLY, render the operator\n\t\t\tbuffer += operator\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space after + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else {\n\t\t\t\t// Add optional space after other operators (like *, /, and ,)\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\n\t\tif (node.type !== TYPE_OPERATOR) {\n\t\t\tif (item.next !== null) {\n\t\t\t\tif (item.next.data.type !== TYPE_OPERATOR) {\n\t\t\t\t\tbuffer += SPACE\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/** @param {import('css-tree').Dimension} node */\nfunction print_dimension(node) {\n\tlet unit = node.unit\n\tlet buffer = node.value\n\tbuffer += is_uppercase(unit) ? unit.toLowerCase() : unit;\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (is_uppercase(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} [indent_level=0]\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = EMPTY_STRING\n\n\t/** @type {import('css-tree').List<import('css-tree').CssNode>} */\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_RULE) {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\t/** @type {import('css-tree').CssNode} */\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? EMPTY_STRING : '\\t'\n\tNEWLINE = minify ? EMPTY_STRING : '\\n'\n\tOPTIONAL_SPACE = minify ? EMPTY_STRING : ' '\n\tLAST_SEMICOLON = minify ? EMPTY_STRING : ';'\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["SPACE","EMPTY_STRING","TYPE_ATRULE","TYPE_RULE","TYPE_BLOCK","TYPE_SELECTORLIST","TYPE_SELECTOR","TYPE_DECLARATION","TYPE_OPERATOR","NEWLINE","TAB","OPTIONAL_SPACE","LAST_SEMICOLON","indent","size","repeat","is_uppercase","str","test","substr","node","css","loc","start","end","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","type","children","forEach","selector","item","print_simple_selector","print_selector","print_unknown","next","print_selectorlist","print_block","child","name","grandchild","nth","a","b","startsWith","isEmpty","property","charCodeAt","toLowerCase","value","print_value","print_declaration","prev","data","print_atrule","includes","print_prelude","print_list","print_function","unit","print_dimension","operator","trim","code","substr_raw","format","_temp","_ref$minify","minify","ast","parse","positions","parseAtrulePrelude","parseCustomProperty","parseValue","print"],"mappings":"yHAGMA,EAAQ,IACRC,EAAe,GACfC,EAAc,SACdC,EAAY,OACZC,EAAa,QACbC,EAAoB,eACpBC,EAAgB,WAChBC,EAAmB,cACnBC,EAAgB,WAGlBC,EAAU,KACVC,EAAM,KACNC,EAAiB,IACjBC,EAAiB,IAOrB,SAASC,EAAOC,GACf,OAAOJ,EAAIK,OAAOD,EACnB,CAMA,SAASE,EAAaC,GACrB,MAAO,QAAQC,KAAKD,EACrB,CAOA,SAASE,EAAOC,EAAMC,GACrB,IAAIC,EAAMF,EAAKE,IAEf,IAAKA,EAAK,OAAOrB,EAEjB,IAAIsB,EAAQD,EAAIC,MACZC,EAAMF,EAAIE,IACVP,EAAMI,EAAII,UAAUF,EAAMG,OAAQF,EAAIE,QAG1C,OAAIH,EAAMI,OAASH,EAAIG,KACfV,EAIDA,EAAIW,QAAQ,OAAQ5B,EAC5B,CAmBA,SAAS6B,EAAWT,EAAMC,EAAKS,GAC9B,IAAIC,EACAC,EAAUZ,EAAKY,QACfC,EAAQb,EAAKa,MAajB,OAVCF,EADGC,EAAQE,OAAS7B,EAoBtB,SAA4Be,EAAMC,EAAKS,GACtC,IAAIC,EAAS9B,EAeb,OAdemB,EAAKe,SAEXC,QAAQ,SAACC,EAAUC,GAE1BP,GADGM,EAASH,OAAS5B,EAoHxB,SAAwBc,EAAMC,EAAKS,GACl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KvD,EAAK,EACxB,iCAOO,SAAgBA,GACtB,OAAOmD,EAAOnD,EAAK,CAAEsD,QAAQ,GAC9B"}
@@ -1,2 +1,2 @@
1
- import e from"css-tree/parser";let t="\n",r="\t",n=" ";function l(e){return r.repeat(e)}function o(e,t){let r=e.loc;if(!r)return"";let n=r.start,l=r.end,o=t.substring(n.offset,l.offset);return n.line===l.line?o:o.replace(/\s+/g," ")}function u(e,r,n){let l,o=e.prelude,u=e.block;return l=void 0!==o&&"SelectorList"===o.type?function(e,r,n){let l="",o=e.children;for(let e of o)l+="Selector"===e.type?c(e,r,n):m(e,r,n),e!==o.last&&(l+=","+t);return l}(o,r,n):m(o,r,n),null!==u&&"Block"===u.type&&(l+=s(u,r,n)),l}function i(e,t){let r="";if(e.children)for(let n of e.children)switch(n.type){case"Combinator":r+=" "," "!==n.name&&(r+=n.name+" ");break;case"PseudoClassSelector":r+=":"+n.name,n.children&&(r+="("+i(n,t)+")");break;case"SelectorList":for(let e of n.children)"Selector"===e.type&&(r+=i(e,t)),e!==n.children.last&&(r+=", ");break;case"Nth":if(n.nth)if("AnPlusB"===n.nth.type){let e=n.nth.a,t=n.nth.b;null!==e&&(r+=e+"n"),null!==e&&null!==t&&(r+=" "),null!==t&&(null===e||t.startsWith("-")||(r+="+ "),r+=t)}else r+=o(n.nth,t);null!==n.selector&&(r+=" of "+i(n.selector,t));break;default:r+=o(n,t)}return r}function c(e,t,r){return l(r)+i(e,t)}function s(e,r,o){let i,c=e.children,s=n;if(c.isEmpty)return s+"{}";s+="{"+t,o++;for(let e of c)"Declaration"===e.type?s+=f(e,r,o)+";":("Declaration"===i&&(s+=t),s+="Rule"===e.type?u(e,r,o):"Atrule"===e.type?a(e,r,o):m(e,r,o)),e!==c.last&&(s+=t,"Declaration"!==e.type&&(s+=t)),i=e.type;return o--,s+=t,s+=l(o)+"}",s}function a(e,t,r){let n=l(r)+"@"+e.name.toLowerCase(),u=e.prelude,i=e.block;return null!==u&&(n+=" "+function(e,t){return o(e,t).replace(/\s*([:,])/g,"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g," ")}(u,t)),null===i?n+=";":"Block"===i.type&&(n+=s(i,t,r)),n}function f(e,t,r){let o=e.property;!o.startsWith("--")&&/[A-Z]/.test(o)&&(o=o.toLowerCase());let u=d(e.value,t).trim();return"font"===o&&(u=u.replace(/\s*\/\s*/,"/")),l(r)+o+":"+n+u}function p(e,t){let r="";for(let n of e)n!==e.first&&"Operator"!==n.type&&(r+=" "),"Identifier"===n.type?r+=n.name:"Function"===n.type?r+=h(n,t):"Dimension"===n.type?r+=y(n):"Value"===n.type?r+=d(n,t):"Operator"===n.type?(","!==n.value&&(r+=" "),r+=o(n,t)):r+=o(n,t);return r}function y(e){return e.value+e.unit.toLowerCase()}function d(e,t){return"Raw"===e.type?m(e,t,0):p(e.children,t)}function h(e,t){let r=e.name,n=r;return/[A-Z]/.test(r)&&(n=r.toLowerCase()),n+="(",n+=p(e.children,t),n+=")",n}function m(e,t,r){return l(r)+function(e,t){let r=e.loc;return r?t.substring(r.start.offset,r.end.offset):""}(e,t).trim()}function b(l,{minify:o=!1}={}){let i=e(l,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return r=o?"":"\t",t=o?"":"\n",n=o?"":" ",function(e,r,n=0){let l="",o=e.children;for(let e of o)l+="Rule"===e.type?u(e,r,n):"Atrule"===e.type?a(e,r,n):m(e,r,n),e!==o.last&&(l+=t+t);return l}(i,l,0)}function k(e){return b(e,{minify:!0})}export{b as format,k as minify};
1
+ import e from"css-tree/parser";const t=" ",n="",r="Atrule",l="Rule",u="Block",o="SelectorList",c="Selector",i="Declaration",a="Operator";let s="\n",f="\t",p=" ",y=";";function d(e){return f.repeat(e)}function h(e){return/[A-Z]/.test(e)}function m(e,r){let l=e.loc;if(!l)return n;let u=l.start,o=l.end,c=r.substring(u.offset,o.offset);return u.line===o.line?c:c.replace(/\s+/g,t)}function b(e,t,r){let l,i=e.prelude,a=e.block;return l=i.type===o?function(e,t,r){let l=n;return e.children.forEach((e,n)=>{l+=e.type===c?function(e,t,n){return d(n)+C(e,t)}(e,t,r):E(e,t,r),null!==n.next&&(l+=","+s)}),l}(i,t,r):E(i,t,r),a.type===u&&(l+=x(a,t,r)),l}function C(e,r){let l=n;return e.children?(e.children.forEach(e=>{switch(e.type){case"Combinator":l+=t," "!==e.name&&(l+=e.name+t);break;case"PseudoClassSelector":l+=":","before"!==e.name&&"after"!==e.name||(l+=":"),l+=e.name,e.children&&(l+="("+C(e,r)+")");break;case o:e.children.forEach((e,n)=>{e.type===c&&(l+=C(e,r)),n.next&&(l+=","+t)});break;case"Nth":{let n=e.nth;if(n)if("AnPlusB"===n.type){let e=n.a,r=n.b;null!==e&&(l+=e+"n"),null!==e&&null!==r&&(l+=t),null!==r&&(null===e||r.startsWith("-")||(l+="+"+t),l+=r)}else l+=m(e.nth,r);null!==e.selector&&(l+=t+"of"+t+C(e.selector,r));break}default:l+=m(e,r)}}),l):l}function x(e,t,n){let u=e.children,o=p;return u.isEmpty?o+"{}":(o+="{"+s,n++,u.forEach((e,u)=>{e.type===i?(o+=function(e,t,n){let r=e.property;45===r.charCodeAt(0)&&45===r.charCodeAt(1)||h(r)&&(r=r.toLowerCase());let l=A(e.value,t);return"font"===r&&(l=l.replace(/\s*\/\s*/,"/")),d(n)+r+":"+p+l}(e,t,n),o+=null===u.next?y:";"):(null!==u.prev&&u.prev.data.type===i&&(o+=s),o+=e.type===l?b(e,t,n):e.type===r?g(e,t,n):E(e,t,n)),null!==u.next&&(o+=s,e.type!==i&&(o+=s))}),n--,o+=s,o+=d(n)+"}",o)}function g(e,n,r){let l=d(r)+"@",o=e.name,c=e.prelude,i=e.block;return l+=h(o)?o.toLowerCase():o,null!==c&&(l+=t+function(e,n){let r=m(e,n);return r.replace(/\s*([:,])/g,r.includes("selector(")?"$1":"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g,t)}(c,n)),null===i?l+=";":i.type===u&&(l+=x(i,n,r)),l}function k(e,r){let l=n;return e.forEach((e,n)=>{if("Identifier"===e.type)l+=e.name;else if("Function"===e.type)l+=function(e,t){let n=e.name,r=n;return h(n)&&(r=n.toLowerCase()),r+="(",r+=k(e.children,t),r+=")",r}(e,r);else if("Dimension"===e.type)l+=function(e){let t=e.unit,n=e.value;return n+=h(t)?t.toLowerCase():t,n}(e);else if("Value"===e.type)l+=A(e,r);else if(e.type===a){let n=e.value.trim(),r=n.charCodeAt(0);43===r||45===r?l+=t:44!==r&&(l+=p),l+=n,l+=43===r||45===r?t:p}else l+=m(e,r);e.type!==a&&null!==n.next&&n.next.data.type!==a&&(l+=t)}),l}function A(e,t){return"Raw"===e.type?E(e,t,0):k(e.children,t)}function E(e,t,r){return d(r)+function(e,t){let r=e.loc;return r?t.substring(r.start.offset,r.end.offset):n}(e,t).trim()}function w(t,{minify:u=!1}={}){let o=e(t,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return f=u?n:"\t",s=u?n:"\n",p=u?n:" ",y=u?n:";",function(e,t,u=0){let o=n;return e.children.forEach((e,n)=>{o+=e.type===l?b(e,t,u):e.type===r?g(e,t,u):E(e,t,u),null!==n.next&&(o+=s+s)}),o}(o,t,0)}function v(e){return w(e,{minify:!0})}export{w as format,v as minify};
2
2
  //# sourceMappingURL=format.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.modern.js","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet SPACE = ' ' // or ''\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return ''\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, ' ')\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return ''\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude !== undefined && prelude.type === 'SelectorList') {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block !== null && block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = ''\n\tlet children = node.children\n\n\tfor (let selector of children) {\n\t\tif (selector.type === 'Selector') {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (selector !== children.last) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = ''\n\n\tif (node.children) {\n\t\tfor (let child of node.children) {\n\t\t\tswitch (child.type) {\n\t\t\t\tcase 'Combinator': {\n\t\t\t\t\t// putting spaces around `child.name`, unless the combinator is ' '\n\t\t\t\t\tbuffer += ' '\n\t\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\t\tbuffer += child.name + ' '\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\t\tbuffer += ':' + child.name\n\n\t\t\t\t\tif (child.children) {\n\t\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'SelectorList': {\n\t\t\t\t\tfor (let grandchild of child.children) {\n\t\t\t\t\t\tif (grandchild.type === 'Selector') {\n\t\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (grandchild !== child.children.last) {\n\t\t\t\t\t\t\tbuffer += ', '\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'Nth': {\n\t\t\t\t\tif (child.nth) {\n\t\t\t\t\t\tif (child.nth.type === 'AnPlusB') {\n\t\t\t\t\t\t\tlet a = child.nth.a\n\t\t\t\t\t\t\tlet b = child.nth.b\n\n\t\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\t\tbuffer += ' '\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\t\tbuffer += '+ '\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t\t// `of .selector`\n\t\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\t\tbuffer += ' of ' + print_simple_selector(child.selector, css)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbuffer += substr(child, css)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tlet prev_type\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Declaration') {\n\t\t\tbuffer += print_declaration(child, css, indent_level) + ';'\n\t\t} else {\n\t\t\tif (prev_type === 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === 'Rule') {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === 'Atrule') {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\n\t\tprev_type = child.type\n\t}\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@' + node.name.toLowerCase()\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += ' ' + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, '$1 ') // force whitespace after colon or comma\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, ' ') // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\tif (!property.startsWith('--') && /[A-Z]/.test(property)) {\n\t\tproperty = property.toLowerCase()\n\t}\n\n\tlet value = print_value(node.value, css).trim()\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = ''\n\n\tfor (let node of children) {\n\t\tif (node !== children.first && node.type !== 'Operator') {\n\t\t\tbuffer += ' '\n\t\t}\n\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === 'Operator') {\n\t\t\t// Put extra spacing before + - / *\n\t\t\t// but not before a comma\n\t\t\tif (node.value !== ',') {\n\t\t\t\tbuffer += ' '\n\t\t\t}\n\t\t\tbuffer += substr(node, css)\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Dimension} node\n */\nfunction print_dimension(node) {\n\treturn node.value + node.unit.toLowerCase()\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (/[A-Z]/.test(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {number} indent_level\n * @param {string} css\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = ''\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Rule') {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === 'Atrule') {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? '' : '\\t'\n\tNEWLINE = minify ? '' : '\\n'\n\tSPACE = minify ? '' : ' '\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["NEWLINE","TAB","SPACE","indent","size","repeat","substr","node","css","loc","start","end","str","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","undefined","type","children","selector","print_selector","print_unknown","last","print_selectorlist","print_block","print_simple_selector","child","name","grandchild","nth","a","b","startsWith","prev_type","isEmpty","print_declaration","print_atrule","toLowerCase","print_prelude","property","test","value","print_value","trim","print_list","first","print_function","print_dimension","unit","substr_raw","format","minify","ast","parse","positions","parseAtrulePrelude","parseCustomProperty","parseValue","print"],"mappings":"+BAIA,IAAIA,EAAU,KACVC,EAAM,KACNC,EAAQ,IAOZ,SAASC,EAAOC,GACf,OAAOH,EAAII,OAAOD,EACnB,CAOA,SAASE,EAAOC,EAAMC,GACrB,IAAIC,EAAMF,EAAKE,IAEf,IAAKA,EAAK,MAAO,GAEjB,IAAIC,EAAQD,EAAIC,MACZC,EAAMF,EAAIE,IACVC,EAAMJ,EAAIK,UAAUH,EAAMI,OAAQH,EAAIG,QAG1C,OAAIJ,EAAMK,OAASJ,EAAII,KACfH,EAIDA,EAAII,QAAQ,OAAQ,IAC5B,CAmBA,SAASC,EAAWV,EAAMC,EAAKU,GAC9B,IAAIC,EACAC,EAAUb,EAAKa,QACfC,EAAQd,EAAKc,MAYjB,OATCF,OADeG,IAAZF,GAA0C,iBAAjBA,EAAQG,KAmBtC,SAA4BhB,EAAMC,EAAKU,GACtC,IAAIC,EAAS,GACTK,EAAWjB,EAAKiB,SAEpB,IAAK,IAAIC,KAAYD,EAEnBL,GADqB,aAAlBM,EAASF,KACFG,EAAeD,EAAUjB,EAAKU,GAE9BS,EAAcF,EAAUjB,EAAKU,GAGpCO,IAAaD,EAASI,OACzBT,GAAW,IAAKnB,GAGlB,OAAOmB,CACR,CAlCWU,CAAmBT,EAASZ,EAAKU,GAEjCS,EAAcP,EAASZ,EAAKU,GAGxB,OAAVG,GAAiC,UAAfA,EAAME,OAC3BJ,GAAUW,EAAYT,EAAOb,EAAKU,IAG5BC,CACR,CA8BA,SAASY,EAAsBxB,EAAMC,GACpC,IAAIW,EAAS,GAEb,GAAIZ,EAAKiB,SACR,IAAK,IAAIQ,KAASzB,EAAKiB,SACtB,OAAQQ,EAAMT,M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We,EAAOxB,EAAKU,GACR,WAAfc,EAAMT,KACNmB,EAAaV,EAAOxB,EAAKU,GAEzBS,EAAcK,EAAOxB,EAAKU,GAGjCc,IAAUR,EAASI,OACtBT,GAAUnB,EAAUA,GAItB,OAAOmB,CACR,CAuBQ6C,CAAMN,EAAKlD,EAAK,EACxB,UAOgBiD,EAAOjD,GACtB,OAAOgD,EAAOhD,EAAK,CAAEiD,QAAQ,GAC9B"}
1
+ {"version":3,"file":"format.modern.js","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\nconst SPACE = ' '\nconst EMPTY_STRING = ''\nconst TYPE_ATRULE = 'Atrule'\nconst TYPE_RULE = 'Rule'\nconst TYPE_BLOCK = 'Block'\nconst TYPE_SELECTORLIST = 'SelectorList'\nconst TYPE_SELECTOR = 'Selector'\nconst TYPE_DECLARATION = 'Declaration'\nconst TYPE_OPERATOR = 'Operator'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet OPTIONAL_SPACE = ' ' // or ''\nlet LAST_SEMICOLON = ';'\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * Check if a string contains uppercase characters\n * @param {string} str\n */\nfunction is_uppercase(str) {\n\treturn /[A-Z]/.test(str)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return EMPTY_STRING\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, SPACE)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return EMPTY_STRING\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude.type === TYPE_SELECTORLIST) {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\t// In case parsing the selector list fails we'll print it as-is\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = EMPTY_STRING\n\tlet children = node.children\n\n\tchildren.forEach((selector, item) => {\n\t\tif (selector.type === TYPE_SELECTOR) {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = EMPTY_STRING\n\n\tif (!node.children) {\n\t\treturn buffer\n\t}\n\n\tnode.children.forEach((child) => {\n\t\tswitch (child.type) {\n\t\t\tcase 'Combinator': {\n\t\t\t\t// putting spaces around `child.name` (+ > ~ or ' '), unless the combinator is ' '\n\t\t\t\tbuffer += SPACE\n\n\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\tbuffer += child.name + SPACE\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\tbuffer += ':'\n\n\t\t\t\t// Special case for `:before` and `:after` which were used in CSS2 and are usually minified\n\t\t\t\t// as `:before` and `:after`, but we want to keep them as `::before` and `::after`\n\t\t\t\tif (child.name === 'before' || child.name === 'after') {\n\t\t\t\t\tbuffer += ':'\n\t\t\t\t}\n\n\t\t\t\tbuffer += child.name\n\n\t\t\t\tif (child.children) {\n\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase TYPE_SELECTORLIST: {\n\t\t\t\tchild.children.forEach((grandchild, item) => {\n\t\t\t\t\tif (grandchild.type === TYPE_SELECTOR) {\n\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t}\n\n\t\t\t\t\tif (item.next) {\n\t\t\t\t\t\tbuffer += ',' + SPACE\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Nth': {\n\t\t\t\tlet nth = child.nth\n\t\t\t\tif (nth) {\n\t\t\t\t\tif (nth.type === 'AnPlusB') {\n\t\t\t\t\t\tlet a = nth.a\n\t\t\t\t\t\tlet b = nth.b\n\n\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\tbuffer += SPACE\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\tbuffer += '+' + SPACE\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t// `of .selector`\n\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\tbuffer += SPACE + 'of' + SPACE + print_simple_selector(child.selector, css)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbuffer += substr(child, css)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = OPTIONAL_SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_DECLARATION) {\n\t\t\tbuffer += print_declaration(child, css, indent_level)\n\n\t\t\tif (item.next === null) {\n\t\t\t\tbuffer += LAST_SEMICOLON\n\t\t\t} else {\n\t\t\t\tbuffer += ';'\n\t\t\t}\n\t\t} else {\n\t\t\tif (item.prev !== null && item.prev.data.type === TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === TYPE_RULE) {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\t})\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@'\n\tlet name = node.name\n\tlet prelude = node.prelude\n\tlet block = node.block\n\tbuffer += is_uppercase(name) ? name.toLowerCase() : name\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += SPACE + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, buffer.includes('selector(') ? '$1' : '$1 ') // force whitespace after colon or comma, except inside `selector()`\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, SPACE) // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\t// Lowercase the property, unless it's a custom property (starts with --)\n\tif (!(property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45)) { // 45 == '-'\n\t\tif (is_uppercase(property)) {\n\t\t\tproperty = property.toLowerCase()\n\t\t}\n\t}\n\n\tlet value = print_value(node.value, css)\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + OPTIONAL_SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = EMPTY_STRING\n\n\tchildren.forEach((node, item) => {\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === TYPE_OPERATOR) {\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/CSS/calc#notes\n\t\t\t// The + and - operators must be surrounded by whitespace\n\t\t\t// Whitespace around other operators is optional\n\n\t\t\t// Trim the operator because CSSTree adds whitespace around it\n\t\t\tlet operator = node.value.trim()\n\t\t\tlet code = operator.charCodeAt(0)\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space before + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else if (code !== 44) { // ,\n\t\t\t\t// Add optional space before operator\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\n\t\t\t// FINALLY, render the operator\n\t\t\tbuffer += operator\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space after + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else {\n\t\t\t\t// Add optional space after other operators (like *, /, and ,)\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\n\t\tif (node.type !== TYPE_OPERATOR) {\n\t\t\tif (item.next !== null) {\n\t\t\t\tif (item.next.data.type !== TYPE_OPERATOR) {\n\t\t\t\t\tbuffer += SPACE\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/** @param {import('css-tree').Dimension} node */\nfunction print_dimension(node) {\n\tlet unit = node.unit\n\tlet buffer = node.value\n\tbuffer += is_uppercase(unit) ? unit.toLowerCase() : unit;\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (is_uppercase(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} [indent_level=0]\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = EMPTY_STRING\n\n\t/** @type {import('css-tree').List<import('css-tree').CssNode>} */\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_RULE) {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\t/** @type {import('css-tree').CssNode} */\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? EMPTY_STRING : '\\t'\n\tNEWLINE = minify ? EMPTY_STRING : '\\n'\n\tOPTIONAL_SPACE = minify ? EMPTY_STRING : ' '\n\tLAST_SEMICOLON = minify ? EMPTY_STRING : ';'\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["SPACE","EMPTY_STRING","TYPE_ATRULE","TYPE_RULE","TYPE_BLOCK","TYPE_SELECTORLIST","TYPE_SELECTOR","TYPE_DECLARATION","TYPE_OPERATOR","NEWLINE","TAB","OPTIONAL_SPACE","LAST_SEMICOLON","indent","size","repeat","is_uppercase","str","test","substr","node","css","loc","start","end","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","type","children","forEach","selector","item","print_simple_selector","print_selector","print_unknown","next","print_selectorlist","print_block","child","name","grandchild","nth","a","b","startsWith","isEmpty","property","charCodeAt","toLowerCase","value","print_value","print_declaration","prev","data","print_atrule","includes","print_prelude","print_list","print_function","unit","print_dimension","operator","trim","code","substr_raw","format","minify","ast","parse","positions","parseA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crB,EAAMC,EAAKS,GACjC,OAAOjB,EAAOiB,GA/Yf,SAAoBV,EAAMC,GACzB,IAAIC,EAAMF,EAAKE,IACf,OAAKA,EACED,EAAII,UAAUH,EAAIC,MAAMG,OAAQJ,EAAIE,IAAIE,QAD9BzB,CAElB,CA2Y+BsE,CAAWnD,EAAMC,GAAKgD,MACrD,CAyCO,SAASG,EAAOnD,GAAKoD,OAAEA,GAAS,GAAU,CAAA,GAEhD,IAAIC,EAAMC,EAAMtD,EAAK,CACpBuD,WAAW,EACXC,oBAAoB,EACpBC,qBAAqB,EACrBC,YAAY,IAQb,OALArE,EAAM+D,EAASxE,EAAe,KAC9BQ,EAAUgE,EAASxE,EAAe,KAClCU,EAAiB8D,EAASxE,EAAe,IACzCW,EAAiB6D,EAASxE,EAAe,IA7C1C,SAAemB,EAAMC,EAAKS,EAAe,GACxC,IAAIC,EAAS9B,EAoBb,OAhBemB,EAAKe,SAEXC,QAAQ,CAACS,EAAOP,KAEvBP,GADGc,EAAMX,OAAS/B,EACR0B,EAAWgB,EAAOxB,EAAKS,GACvBe,EAAMX,OAAShC,EACf2D,EAAahB,EAAOxB,EAAKS,GAEzBW,EAAcI,EAAOxB,EAAKS,GAGnB,OAAdQ,EAAKI,OACRX,GAAUtB,EAAUA,EACrB,GAGMsB,CACR,CAyBQiD,CAAMN,EAAKrD,EAAK,EACxB,CAOO,SAASoD,EAAOpD,GACtB,OAAOmD,EAAOnD,EAAK,CAAEoD,QAAQ,GAC9B"}
@@ -1,2 +1,2 @@
1
- import e from"css-tree/parser";function r(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function t(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n="\n",a="\t",o=" ";function l(e){return a.repeat(e)}function u(e,r){var t=e.loc;if(!t)return"";var n=t.start,a=t.end,o=r.substring(n.offset,a.offset);return n.line===a.line?o:o.replace(/\s+/g," ")}function i(e,r,a){var o,l=e.prelude,u=e.block;return o=void 0!==l&&"SelectorList"===l.type?function(e,r,a){for(var o,l="",u=e.children,i=t(u);!(o=i()).done;){var c=o.value;l+="Selector"===c.type?s(c,r,a):b(c,r,a),c!==u.last&&(l+=","+n)}return l}(l,r,a):b(l,r,a),null!==u&&"Block"===u.type&&(o+=f(u,r,a)),o}function c(e,r){var n="";if(e.children)for(var a,o=t(e.children);!(a=o()).done;){var l=a.value;switch(l.type){case"Combinator":n+=" "," "!==l.name&&(n+=l.name+" ");break;case"PseudoClassSelector":n+=":"+l.name,l.children&&(n+="("+c(l,r)+")");break;case"SelectorList":for(var i,s=t(l.children);!(i=s()).done;){var f=i.value;"Selector"===f.type&&(n+=c(f,r)),f!==l.children.last&&(n+=", ")}break;case"Nth":if(l.nth)if("AnPlusB"===l.nth.type){var p=l.nth.a,v=l.nth.b;null!==p&&(n+=p+"n"),null!==p&&null!==v&&(n+=" "),null!==v&&(null===p||v.startsWith("-")||(n+="+ "),n+=v)}else n+=u(l.nth,r);null!==l.selector&&(n+=" of "+c(l.selector,r));break;default:n+=u(l,r)}}return n}function s(e,r,t){return l(t)+c(e,r)}function f(e,r,a){var u,c=e.children,s=o;if(c.isEmpty)return s+"{}";s+="{"+n,a++;for(var f,y=t(c);!(f=y()).done;){var d=f.value;"Declaration"===d.type?s+=v(d,r,a)+";":("Declaration"===u&&(s+=n),s+="Rule"===d.type?i(d,r,a):"Atrule"===d.type?p(d,r,a):b(d,r,a)),d!==c.last&&(s+=n,"Declaration"!==d.type&&(s+=n)),u=d.type}return a--,(s+=n)+(l(a)+"}")}function p(e,r,t){var n=l(t)+"@"+e.name.toLowerCase(),a=e.prelude,o=e.block;return null!==a&&(n+=" "+function(e,r){return u(e,r).replace(/\s*([:,])/g,"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g," ")}(a,r)),null===o?n+=";":"Block"===o.type&&(n+=f(o,r,t)),n}function v(e,r,t){var n=e.property;!n.startsWith("--")&&/[A-Z]/.test(n)&&(n=n.toLowerCase());var a=m(e.value,r).trim();return"font"===n&&(a=a.replace(/\s*\/\s*/,"/")),l(t)+n+":"+o+a}function y(e,r){for(var n,a="",o=t(e);!(n=o()).done;){var l=n.value;l!==e.first&&"Operator"!==l.type&&(a+=" "),"Identifier"===l.type?a+=l.name:"Function"===l.type?a+=h(l,r):"Dimension"===l.type?a+=d(l):"Value"===l.type?a+=m(l,r):"Operator"===l.type?(","!==l.value&&(a+=" "),a+=u(l,r)):a+=u(l,r)}return a}function d(e){return e.value+e.unit.toLowerCase()}function m(e,r){return"Raw"===e.type?b(e,r,0):y(e.children,r)}function h(e,r){var t=e.name,n=t;return/[A-Z]/.test(t)&&(n=t.toLowerCase()),n+="(",(n+=y(e.children,r))+")"}function b(e,r,t){return l(t)+function(e,r){var t=e.loc;return t?r.substring(t.start.offset,t.end.offset):""}(e,r).trim()}function g(r,l){var u=(void 0===l?{}:l).minify,c=void 0!==u&&u,s=e(r,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return a=c?"":"\t",n=c?"":"\n",o=c?"":" ",function(e,r,a){void 0===a&&(a=0);for(var o,l="",u=e.children,c=t(u);!(o=c()).done;){var s=o.value;l+="Rule"===s.type?i(s,r,a):"Atrule"===s.type?p(s,r,a):b(s,r,a),s!==u.last&&(l+=n+n)}return l}(s,r,0)}function A(e){return g(e,{minify:!0})}export{g as format,A as minify};
1
+ import e from"css-tree/parser";var n=" ",r="",t="Atrule",a="Rule",u="Block",o="SelectorList",l="Selector",i="Declaration",c="Operator",f="\n",s="\t",p=" ",v=";";function y(e){return s.repeat(e)}function d(e){return/[A-Z]/.test(e)}function h(e,t){var a=e.loc;if(!a)return r;var u=a.start,o=a.end,l=t.substring(u.offset,o.offset);return u.line===o.line?l:l.replace(/\s+/g,n)}function m(e,n,t){var a,i=e.prelude,c=e.block;return a=i.type===o?function(e,n,t){var a=r;return e.children.forEach(function(e,r){a+=e.type===l?function(e,n,r){return y(r)+b(e,n)}(e,n,t):A(e,n,t),null!==r.next&&(a+=","+f)}),a}(i,n,t):A(i,n,t),c.type===u&&(a+=C(c,n,t)),a}function b(e,t){var a=r;return e.children?(e.children.forEach(function(e){switch(e.type){case"Combinator":a+=n," "!==e.name&&(a+=e.name+n);break;case"PseudoClassSelector":a+=":","before"!==e.name&&"after"!==e.name||(a+=":"),a+=e.name,e.children&&(a+="("+b(e,t)+")");break;case o:e.children.forEach(function(e,r){e.type===l&&(a+=b(e,t)),r.next&&(a+=","+n)});break;case"Nth":var r=e.nth;if(r)if("AnPlusB"===r.type){var u=r.a,i=r.b;null!==u&&(a+=u+"n"),null!==u&&null!==i&&(a+=n),null!==i&&(null===u||i.startsWith("-")||(a+="+"+n),a+=i)}else a+=h(e.nth,t);null!==e.selector&&(a+=n+"of"+n+b(e.selector,t));break;default:a+=h(e,t)}}),a):a}function C(e,n,r){var u=e.children,o=p;return u.isEmpty?o+"{}":(o+="{"+f,r++,u.forEach(function(e,u){e.type===i?(o+=function(e,n,r){var t=e.property;45===t.charCodeAt(0)&&45===t.charCodeAt(1)||d(t)&&(t=t.toLowerCase());var a=k(e.value,n);return"font"===t&&(a=a.replace(/\s*\/\s*/,"/")),y(r)+t+":"+p+a}(e,n,r),o+=null===u.next?v:";"):(null!==u.prev&&u.prev.data.type===i&&(o+=f),o+=e.type===a?m(e,n,r):e.type===t?x(e,n,r):A(e,n,r)),null!==u.next&&(o+=f,e.type!==i&&(o+=f))}),r--,o+=f,o+=y(r)+"}")}function x(e,r,t){var a=y(t)+"@",o=e.name,l=e.prelude,i=e.block;return a+=d(o)?o.toLowerCase():o,null!==l&&(a+=n+function(e,r){var t=h(e,r);return t.replace(/\s*([:,])/g,t.includes("selector(")?"$1":"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g,n)}(l,r)),null===i?a+=";":i.type===u&&(a+=C(i,r,t)),a}function g(e,t){var a=r;return e.forEach(function(e,r){if("Identifier"===e.type)a+=e.name;else if("Function"===e.type)a+=function(e,n){var r=e.name,t=r;return d(r)&&(t=r.toLowerCase()),t+="(",(t+=g(e.children,n))+")"}(e,t);else if("Dimension"===e.type)a+=function(e){var n=e.unit;return e.value+(d(n)?n.toLowerCase():n)}(e);else if("Value"===e.type)a+=k(e,t);else if(e.type===c){var u=e.value.trim(),o=u.charCodeAt(0);43===o||45===o?a+=n:44!==o&&(a+=p),a+=u,a+=43===o||45===o?n:p}else a+=h(e,t);e.type!==c&&null!==r.next&&r.next.data.type!==c&&(a+=n)}),a}function k(e,n){return"Raw"===e.type?A(e,n,0):g(e.children,n)}function A(e,n,t){return y(t)+function(e,n){var t=e.loc;return t?n.substring(t.start.offset,t.end.offset):r}(e,n).trim()}function E(n,u){var o=(void 0===u?{}:u).minify,l=void 0!==o&&o,i=e(n,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return s=l?r:"\t",f=l?r:"\n",p=l?r:" ",v=l?r:";",function(e,n,u){void 0===u&&(u=0);var o=r;return e.children.forEach(function(e,r){o+=e.type===a?m(e,n,u):e.type===t?x(e,n,u):A(e,n,u),null!==r.next&&(o+=f+f)}),o}(i,n,0)}function w(e){return E(e,{minify:!0})}export{E as format,w as minify};
2
2
  //# sourceMappingURL=format.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.module.js","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet SPACE = ' ' // or ''\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return ''\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, ' ')\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return ''\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude !== undefined && prelude.type === 'SelectorList') {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block !== null && block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = ''\n\tlet children = node.children\n\n\tfor (let selector of children) {\n\t\tif (selector.type === 'Selector') {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (selector !== children.last) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = ''\n\n\tif (node.children) {\n\t\tfor (let child of node.children) {\n\t\t\tswitch (child.type) {\n\t\t\t\tcase 'Combinator': {\n\t\t\t\t\t// putting spaces around `child.name`, unless the combinator is ' '\n\t\t\t\t\tbuffer += ' '\n\t\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\t\tbuffer += child.name + ' '\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\t\tbuffer += ':' + child.name\n\n\t\t\t\t\tif (child.children) {\n\t\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'SelectorList': {\n\t\t\t\t\tfor (let grandchild of child.children) {\n\t\t\t\t\t\tif (grandchild.type === 'Selector') {\n\t\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (grandchild !== child.children.last) {\n\t\t\t\t\t\t\tbuffer += ', '\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'Nth': {\n\t\t\t\t\tif (child.nth) {\n\t\t\t\t\t\tif (child.nth.type === 'AnPlusB') {\n\t\t\t\t\t\t\tlet a = child.nth.a\n\t\t\t\t\t\t\tlet b = child.nth.b\n\n\t\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\t\tbuffer += ' '\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\t\tbuffer += '+ '\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t\t// `of .selector`\n\t\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\t\tbuffer += ' of ' + print_simple_selector(child.selector, css)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbuffer += substr(child, css)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tlet prev_type\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Declaration') {\n\t\t\tbuffer += print_declaration(child, css, indent_level) + ';'\n\t\t} else {\n\t\t\tif (prev_type === 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === 'Rule') {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === 'Atrule') {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\n\t\tprev_type = child.type\n\t}\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@' + node.name.toLowerCase()\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += ' ' + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, '$1 ') // force whitespace after colon or comma\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, ' ') // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\tif (!property.startsWith('--') && /[A-Z]/.test(property)) {\n\t\tproperty = property.toLowerCase()\n\t}\n\n\tlet value = print_value(node.value, css).trim()\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = ''\n\n\tfor (let node of children) {\n\t\tif (node !== children.first && node.type !== 'Operator') {\n\t\t\tbuffer += ' '\n\t\t}\n\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === 'Operator') {\n\t\t\t// Put extra spacing before + - / *\n\t\t\t// but not before a comma\n\t\t\tif (node.value !== ',') {\n\t\t\t\tbuffer += ' '\n\t\t\t}\n\t\t\tbuffer += substr(node, css)\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Dimension} node\n */\nfunction print_dimension(node) {\n\treturn node.value + node.unit.toLowerCase()\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (/[A-Z]/.test(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {number} indent_level\n * @param {string} css\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = ''\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Rule') {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === 'Atrule') {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? '' : '\\t'\n\tNEWLINE = minify ? '' : '\\n'\n\tSPACE = minify ? '' : ' '\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["NEWLINE","TAB","SPACE","indent","size","repeat","substr","node","css","loc","start","end","str","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","undefined","type","_step","children","_iterator","_createForOfIteratorHelperLoose","done","selector","value","print_selector","print_unknown","last","print_selectorlist","print_block","print_simple_selector","_step2","_iterator2","child","name","_iterator3","_step3","grandchild","nth","a","b","startsWith","prev_type","isEmpty","_step4","_iterator4","print_declaration","print_atrule","toLowerCase","print_prelude","property","test","print_value","trim","print_list","_step5","_iterator5","first","print_function","print_dimension","unit","substr_raw","format","_temp","_ref","_ref$minify","minify","ast","parse","positions","parseAtrulePrelude","parseCustomProperty","parseValue","_step6","_iterator6","print"],"mappings":"q1BAIA,IAAIA,EAAU,KACVC,EAAM,KACNC,EAAQ,IAOZ,SAASC,EAAOC,GACf,OAAOH,EAAII,OAAOD,EACnB,CAOA,SAASE,EAAOC,EAAMC,GACrB,IAAIC,EAAMF,EAAKE,IAEf,IAAKA,EAAK,MAAO,GAEjB,IAAIC,EAAQD,EAAIC,MACZC,EAAMF,EAAIE,IACVC,EAAMJ,EAAIK,UAAUH,EAAMI,OAAQH,EAAIG,QAG1C,OAAIJ,EAAMK,OAASJ,EAAII,KACfH,EAIDA,EAAII,QAAQ,OAAQ,IAC5B,CAmBA,SAASC,EAAWV,EAAMC,EAAKU,GAC9B,IAAIC,EACAC,EAAUb,EAAKa,QACfC,EAAQd,EAAKc,MAYjB,OATCF,OADeG,IAAZF,GAA0C,iBAAjBA,EAAQG,KAmBtC,SAA4BhB,EAAMC,EAAKU,GAItC,IAHA,IAG6BM,EAHzBL,EAAS,GACTM,EAAWlB,EAAKkB,SAEpB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AAO5D,EAAK,CAAEgE,QAAQ,GAC9B"}
1
+ {"version":3,"file":"format.module.js","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\nconst SPACE = ' '\nconst EMPTY_STRING = ''\nconst TYPE_ATRULE = 'Atrule'\nconst TYPE_RULE = 'Rule'\nconst TYPE_BLOCK = 'Block'\nconst TYPE_SELECTORLIST = 'SelectorList'\nconst TYPE_SELECTOR = 'Selector'\nconst TYPE_DECLARATION = 'Declaration'\nconst TYPE_OPERATOR = 'Operator'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet OPTIONAL_SPACE = ' ' // or ''\nlet LAST_SEMICOLON = ';'\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * Check if a string contains uppercase characters\n * @param {string} str\n */\nfunction is_uppercase(str) {\n\treturn /[A-Z]/.test(str)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return EMPTY_STRING\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, SPACE)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return EMPTY_STRING\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude.type === TYPE_SELECTORLIST) {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\t// In case parsing the selector list fails we'll print it as-is\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = EMPTY_STRING\n\tlet children = node.children\n\n\tchildren.forEach((selector, item) => {\n\t\tif (selector.type === TYPE_SELECTOR) {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = EMPTY_STRING\n\n\tif (!node.children) {\n\t\treturn buffer\n\t}\n\n\tnode.children.forEach((child) => {\n\t\tswitch (child.type) {\n\t\t\tcase 'Combinator': {\n\t\t\t\t// putting spaces around `child.name` (+ > ~ or ' '), unless the combinator is ' '\n\t\t\t\tbuffer += SPACE\n\n\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\tbuffer += child.name + SPACE\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\tbuffer += ':'\n\n\t\t\t\t// Special case for `:before` and `:after` which were used in CSS2 and are usually minified\n\t\t\t\t// as `:before` and `:after`, but we want to keep them as `::before` and `::after`\n\t\t\t\tif (child.name === 'before' || child.name === 'after') {\n\t\t\t\t\tbuffer += ':'\n\t\t\t\t}\n\n\t\t\t\tbuffer += child.name\n\n\t\t\t\tif (child.children) {\n\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase TYPE_SELECTORLIST: {\n\t\t\t\tchild.children.forEach((grandchild, item) => {\n\t\t\t\t\tif (grandchild.type === TYPE_SELECTOR) {\n\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t}\n\n\t\t\t\t\tif (item.next) {\n\t\t\t\t\t\tbuffer += ',' + SPACE\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Nth': {\n\t\t\t\tlet nth = child.nth\n\t\t\t\tif (nth) {\n\t\t\t\t\tif (nth.type === 'AnPlusB') {\n\t\t\t\t\t\tlet a = nth.a\n\t\t\t\t\t\tlet b = nth.b\n\n\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\tbuffer += SPACE\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\tbuffer += '+' + SPACE\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t// `of .selector`\n\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\tbuffer += SPACE + 'of' + SPACE + print_simple_selector(child.selector, css)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbuffer += substr(child, css)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = OPTIONAL_SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_DECLARATION) {\n\t\t\tbuffer += print_declaration(child, css, indent_level)\n\n\t\t\tif (item.next === null) {\n\t\t\t\tbuffer += LAST_SEMICOLON\n\t\t\t} else {\n\t\t\t\tbuffer += ';'\n\t\t\t}\n\t\t} else {\n\t\t\tif (item.prev !== null && item.prev.data.type === TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === TYPE_RULE) {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\t})\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@'\n\tlet name = node.name\n\tlet prelude = node.prelude\n\tlet block = node.block\n\tbuffer += is_uppercase(name) ? name.toLowerCase() : name\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += SPACE + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, buffer.includes('selector(') ? '$1' : '$1 ') // force whitespace after colon or comma, except inside `selector()`\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, SPACE) // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\t// Lowercase the property, unless it's a custom property (starts with --)\n\tif (!(property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45)) { // 45 == '-'\n\t\tif (is_uppercase(property)) {\n\t\t\tproperty = property.toLowerCase()\n\t\t}\n\t}\n\n\tlet value = print_value(node.value, css)\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + OPTIONAL_SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = EMPTY_STRING\n\n\tchildren.forEach((node, item) => {\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === TYPE_OPERATOR) {\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/CSS/calc#notes\n\t\t\t// The + and - operators must be surrounded by whitespace\n\t\t\t// Whitespace around other operators is optional\n\n\t\t\t// Trim the operator because CSSTree adds whitespace around it\n\t\t\tlet operator = node.value.trim()\n\t\t\tlet code = operator.charCodeAt(0)\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space before + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else if (code !== 44) { // ,\n\t\t\t\t// Add optional space before operator\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\n\t\t\t// FINALLY, render the operator\n\t\t\tbuffer += operator\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space after + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else {\n\t\t\t\t// Add optional space after other operators (like *, /, and ,)\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\n\t\tif (node.type !== TYPE_OPERATOR) {\n\t\t\tif (item.next !== null) {\n\t\t\t\tif (item.next.data.type !== TYPE_OPERATOR) {\n\t\t\t\t\tbuffer += SPACE\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/** @param {import('css-tree').Dimension} node */\nfunction print_dimension(node) {\n\tlet unit = node.unit\n\tlet buffer = node.value\n\tbuffer += is_uppercase(unit) ? unit.toLowerCase() : unit;\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (is_uppercase(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} [indent_level=0]\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = EMPTY_STRING\n\n\t/** @type {import('css-tree').List<import('css-tree').CssNode>} */\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_RULE) {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\t/** @type {import('css-tree').CssNode} */\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? EMPTY_STRING : '\\t'\n\tNEWLINE = minify ? EMPTY_STRING : '\\n'\n\tOPTIONAL_SPACE = minify ? EMPTY_STRING : ' '\n\tLAST_SEMICOLON = minify ? EMPTY_STRING : ';'\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["SPACE","EMPTY_STRING","TYPE_ATRULE","TYPE_RULE","TYPE_BLOCK","TYPE_SELECTORLIST","TYPE_SELECTOR","TYPE_DECLARATION","TYPE_OPERATOR","NEWLINE","TAB","OPTIONAL_SPACE","LAST_SEMICOLON","indent","size","repeat","is_uppercase","str","test","substr","node","css","loc","start","end","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","type","children","forEach","selector","item","print_simple_selector","print_selector","print_unknown","next","print_selectorlist","print_block","child","name","grandchild","nth","a","b","startsWith","isEmpty","property","charCodeAt","toLowerCase","value","print_value","print_declaration","prev","data","print_atrule","includes","print_prelude","print_list","print_function","unit","print_dimension","operator","trim","code","substr_raw","format","_temp","_ref$minify","minify","ast","parse","positions","parseAtrulePrelude","parseCustomProperty","parseValue","print"],"mappings":"+BAGA,IAAMA,EAAQ,IACRC,EAAe,GACfC,EAAc,SACdC,EAAY,OACZC,EAAa,QACbC,EAAoB,eACpBC,EAAgB,WAChBC,EAAmB,cACnBC,EAAgB,WAGlBC,EAAU,KACVC,EAAM,KACNC,EAAiB,IACjBC,EAAiB,IAOrB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,QAAF,IAAID,EAAJ,CAAA,EAAEA,GAArBE,OAAAA,OAAS,IAAHD,GAAQA,EAEvCE,EAAMC,EAAMxD,EAAK,CACpByD,WAAW,EACXC,oBAAoB,EACpBC,qBAAqB,EACrBC,YAAY,IAQb,OALAvE,EAAMiE,EAAS1E,EAAe,KAC9BQ,EAAUkE,EAAS1E,EAAe,KAClCU,EAAiBgE,EAAS1E,EAAe,IACzCW,EAAiB+D,EAAS1E,EAAe,IA7C1C,SAAemB,EAAMC,EAAKS,QAAAA,IAAAA,IAAAA,EAAe,GACxC,IAAIC,EAAS9B,EAoBb,OAhBemB,EAAKe,SAEXC,QAAQ,SAACS,EAAOP,GAEvBP,GADGc,EAAMX,OAAS/B,EACR0B,EAAWgB,EAAOxB,EAAKS,GACvBe,EAAMX,OAAShC,EACf2D,EAAahB,EAAOxB,EAAKS,GAEzBW,EAAcI,EAAOxB,EAAKS,GAGnB,OAAdQ,EAAKI,OACRX,GAAUtB,EAAUA,EAEtB,GAEOsB,CACR,CAyBQmD,CAAMN,EAAKvD,EAAK,EACxB,CAOO,SAASsD,EAAOtD,GACtB,OAAOmD,EAAOnD,EAAK,CAAEsD,QAAQ,GAC9B"}
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("css-tree/parser")):"function"==typeof define&&define.amd?define(["exports","css-tree/parser"],r):r((e||self).formatCss={},e.parse)}(this,function(e,r){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(r);function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i="\n",l="\t",u=" ";function c(e){return l.repeat(e)}function f(e,r){var t=e.loc;if(!t)return"";var n=t.start,o=t.end,a=r.substring(n.offset,o.offset);return n.line===o.line?a:a.replace(/\s+/g," ")}function s(e,r,t){var n,o=e.prelude,l=e.block;return n=void 0!==o&&"SelectorList"===o.type?function(e,r,t){for(var n,o="",l=e.children,u=a(l);!(n=u()).done;){var c=n.value;o+="Selector"===c.type?d(c,r,t):S(c,r,t),c!==l.last&&(o+=","+i)}return o}(o,r,t):S(o,r,t),null!==l&&"Block"===l.type&&(n+=v(l,r,t)),n}function p(e,r){var t="";if(e.children)for(var n,o=a(e.children);!(n=o()).done;){var i=n.value;switch(i.type){case"Combinator":t+=" "," "!==i.name&&(t+=i.name+" ");break;case"PseudoClassSelector":t+=":"+i.name,i.children&&(t+="("+p(i,r)+")");break;case"SelectorList":for(var l,u=a(i.children);!(l=u()).done;){var c=l.value;"Selector"===c.type&&(t+=p(c,r)),c!==i.children.last&&(t+=", ")}break;case"Nth":if(i.nth)if("AnPlusB"===i.nth.type){var s=i.nth.a,d=i.nth.b;null!==s&&(t+=s+"n"),null!==s&&null!==d&&(t+=" "),null!==d&&(null===s||d.startsWith("-")||(t+="+ "),t+=d)}else t+=f(i.nth,r);null!==i.selector&&(t+=" of "+p(i.selector,r));break;default:t+=f(i,r)}}return t}function d(e,r,t){return c(t)+p(e,r)}function v(e,r,t){var n,o=e.children,l=u;if(o.isEmpty)return l+"{}";l+="{"+i,t++;for(var f,p=a(o);!(f=p()).done;){var d=f.value;"Declaration"===d.type?l+=m(d,r,t)+";":("Declaration"===n&&(l+=i),l+="Rule"===d.type?s(d,r,t):"Atrule"===d.type?y(d,r,t):S(d,r,t)),d!==o.last&&(l+=i,"Declaration"!==d.type&&(l+=i)),n=d.type}return t--,(l+=i)+(c(t)+"}")}function y(e,r,t){var n=c(t)+"@"+e.name.toLowerCase(),o=e.prelude,a=e.block;return null!==o&&(n+=" "+function(e,r){return f(e,r).replace(/\s*([:,])/g,"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g," ")}(o,r)),null===a?n+=";":"Block"===a.type&&(n+=v(a,r,t)),n}function m(e,r,t){var n=e.property;!n.startsWith("--")&&/[A-Z]/.test(n)&&(n=n.toLowerCase());var o=g(e.value,r).trim();return"font"===n&&(o=o.replace(/\s*\/\s*/,"/")),c(t)+n+":"+u+o}function h(e,r){for(var t,n="",o=a(e);!(t=o()).done;){var i=t.value;i!==e.first&&"Operator"!==i.type&&(n+=" "),"Identifier"===i.type?n+=i.name:"Function"===i.type?n+=A(i,r):"Dimension"===i.type?n+=b(i):"Value"===i.type?n+=g(i,r):"Operator"===i.type?(","!==i.value&&(n+=" "),n+=f(i,r)):n+=f(i,r)}return n}function b(e){return e.value+e.unit.toLowerCase()}function g(e,r){return"Raw"===e.type?S(e,r,0):h(e.children,r)}function A(e,r){var t=e.name,n=t;return/[A-Z]/.test(t)&&(n=t.toLowerCase()),n+="(",(n+=h(e.children,r))+")"}function S(e,r,t){return c(t)+function(e,r){var t=e.loc;return t?r.substring(t.start.offset,t.end.offset):""}(e,r).trim()}function w(e,r){var t=(void 0===r?{}:r).minify,o=void 0!==t&&t,c=n.default(e,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return l=o?"":"\t",i=o?"":"\n",u=o?"":" ",function(e,r,t){void 0===t&&(t=0);for(var n,o="",l=e.children,u=a(l);!(n=u()).done;){var c=n.value;o+="Rule"===c.type?s(c,r,t):"Atrule"===c.type?y(c,r,t):S(c,r,t),c!==l.last&&(o+=i+i)}return o}(c,e,0)}e.format=w,e.minify=function(e){return w(e,{minify:!0})}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("css-tree/parser")):"function"==typeof define&&define.amd?define(["exports","css-tree/parser"],t):t((e||self).formatCss={},e.parse)}(this,function(e,t){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=/*#__PURE__*/n(t),o=" ",u="",a="Atrule",i="Rule",l="Block",c="SelectorList",f="Selector",s="Declaration",p="Operator",d="\n",y="\t",v=" ",h=";";function m(e){return y.repeat(e)}function b(e){return/[A-Z]/.test(e)}function C(e,t){var n=e.loc;if(!n)return u;var r=n.start,a=n.end,i=t.substring(r.offset,a.offset);return r.line===a.line?i:i.replace(/\s+/g,o)}function x(e,t,n){var r,o=e.prelude,a=e.block;return r=o.type===c?function(e,t,n){var r=u;return e.children.forEach(function(e,o){r+=e.type===f?function(e,t,n){return m(n)+g(e,t)}(e,t,n):L(e,t,n),null!==o.next&&(r+=","+d)}),r}(o,t,n):L(o,t,n),a.type===l&&(r+=k(a,t,n)),r}function g(e,t){var n=u;return e.children?(e.children.forEach(function(e){switch(e.type){case"Combinator":n+=o," "!==e.name&&(n+=e.name+o);break;case"PseudoClassSelector":n+=":","before"!==e.name&&"after"!==e.name||(n+=":"),n+=e.name,e.children&&(n+="("+g(e,t)+")");break;case c:e.children.forEach(function(e,r){e.type===f&&(n+=g(e,t)),r.next&&(n+=","+o)});break;case"Nth":var r=e.nth;if(r)if("AnPlusB"===r.type){var u=r.a,a=r.b;null!==u&&(n+=u+"n"),null!==u&&null!==a&&(n+=o),null!==a&&(null===u||a.startsWith("-")||(n+="+"+o),n+=a)}else n+=C(e.nth,t);null!==e.selector&&(n+=o+"of"+o+g(e.selector,t));break;default:n+=C(e,t)}}),n):n}function k(e,t,n){var r=e.children,o=v;return r.isEmpty?o+"{}":(o+="{"+d,n++,r.forEach(function(e,r){e.type===s?(o+=function(e,t,n){var r=e.property;45===r.charCodeAt(0)&&45===r.charCodeAt(1)||b(r)&&(r=r.toLowerCase());var o=w(e.value,t);return"font"===r&&(o=o.replace(/\s*\/\s*/,"/")),m(n)+r+":"+v+o}(e,t,n),o+=null===r.next?h:";"):(null!==r.prev&&r.prev.data.type===s&&(o+=d),o+=e.type===i?x(e,t,n):e.type===a?A(e,t,n):L(e,t,n)),null!==r.next&&(o+=d,e.type!==s&&(o+=d))}),n--,o+=d,o+=m(n)+"}")}function A(e,t,n){var r=m(n)+"@",u=e.name,a=e.prelude,i=e.block;return r+=b(u)?u.toLowerCase():u,null!==a&&(r+=o+function(e,t){var n=C(e,t);return n.replace(/\s*([:,])/g,n.includes("selector(")?"$1":"$1 ").replace(/\s*(=>|<=)\s*/g," $1 ").replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g," $1 ").replace(/\s+/g,o)}(a,t)),null===i?r+=";":i.type===l&&(r+=k(i,t,n)),r}function E(e,t){var n=u;return e.forEach(function(e,r){if("Identifier"===e.type)n+=e.name;else if("Function"===e.type)n+=function(e,t){var n=e.name,r=n;return b(n)&&(r=n.toLowerCase()),r+="(",(r+=E(e.children,t))+")"}(e,t);else if("Dimension"===e.type)n+=function(e){var t=e.unit;return e.value+(b(t)?t.toLowerCase():t)}(e);else if("Value"===e.type)n+=w(e,t);else if(e.type===p){var u=e.value.trim(),a=u.charCodeAt(0);43===a||45===a?n+=o:44!==a&&(n+=v),n+=u,n+=43===a||45===a?o:v}else n+=C(e,t);e.type!==p&&null!==r.next&&r.next.data.type!==p&&(n+=o)}),n}function w(e,t){return"Raw"===e.type?L(e,t,0):E(e.children,t)}function L(e,t,n){return m(n)+function(e,t){var n=e.loc;return n?t.substring(n.start.offset,n.end.offset):u}(e,t).trim()}function P(e,t){var n=(void 0===t?{}:t).minify,o=void 0!==n&&n,l=r.default(e,{positions:!0,parseAtrulePrelude:!1,parseCustomProperty:!0,parseValue:!0});return y=o?u:"\t",d=o?u:"\n",v=o?u:" ",h=o?u:";",function(e,t,n){void 0===n&&(n=0);var r=u;return e.children.forEach(function(e,o){r+=e.type===i?x(e,t,n):e.type===a?A(e,t,n):L(e,t,n),null!==o.next&&(r+=d+d)}),r}(l,e,0)}e.format=P,e.minify=function(e){return P(e,{minify:!0})}});
2
2
  //# sourceMappingURL=format.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.umd.js","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet SPACE = ' ' // or ''\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return ''\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, ' ')\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return ''\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude !== undefined && prelude.type === 'SelectorList') {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block !== null && block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = ''\n\tlet children = node.children\n\n\tfor (let selector of children) {\n\t\tif (selector.type === 'Selector') {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (selector !== children.last) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = ''\n\n\tif (node.children) {\n\t\tfor (let child of node.children) {\n\t\t\tswitch (child.type) {\n\t\t\t\tcase 'Combinator': {\n\t\t\t\t\t// putting spaces around `child.name`, unless the combinator is ' '\n\t\t\t\t\tbuffer += ' '\n\t\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\t\tbuffer += child.name + ' '\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\t\tbuffer += ':' + child.name\n\n\t\t\t\t\tif (child.children) {\n\t\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'SelectorList': {\n\t\t\t\t\tfor (let grandchild of child.children) {\n\t\t\t\t\t\tif (grandchild.type === 'Selector') {\n\t\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (grandchild !== child.children.last) {\n\t\t\t\t\t\t\tbuffer += ', '\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'Nth': {\n\t\t\t\t\tif (child.nth) {\n\t\t\t\t\t\tif (child.nth.type === 'AnPlusB') {\n\t\t\t\t\t\t\tlet a = child.nth.a\n\t\t\t\t\t\t\tlet b = child.nth.b\n\n\t\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\t\tbuffer += ' '\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\t\tbuffer += '+ '\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t\t// `of .selector`\n\t\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\t\tbuffer += ' of ' + print_simple_selector(child.selector, css)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbuffer += substr(child, css)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tlet prev_type\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Declaration') {\n\t\t\tbuffer += print_declaration(child, css, indent_level) + ';'\n\t\t} else {\n\t\t\tif (prev_type === 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === 'Rule') {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === 'Atrule') {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== 'Declaration') {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\n\t\tprev_type = child.type\n\t}\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@' + node.name.toLowerCase()\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += ' ' + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === 'Block') {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, '$1 ') // force whitespace after colon or comma\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, ' ') // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\tif (!property.startsWith('--') && /[A-Z]/.test(property)) {\n\t\tproperty = property.toLowerCase()\n\t}\n\n\tlet value = print_value(node.value, css).trim()\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = ''\n\n\tfor (let node of children) {\n\t\tif (node !== children.first && node.type !== 'Operator') {\n\t\t\tbuffer += ' '\n\t\t}\n\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === 'Operator') {\n\t\t\t// Put extra spacing before + - / *\n\t\t\t// but not before a comma\n\t\t\tif (node.value !== ',') {\n\t\t\t\tbuffer += ' '\n\t\t\t}\n\t\t\tbuffer += substr(node, css)\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\t}\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Dimension} node\n */\nfunction print_dimension(node) {\n\treturn node.value + node.unit.toLowerCase()\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (/[A-Z]/.test(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {number} indent_level\n * @param {string} css\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = ''\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tfor (let child of children) {\n\t\tif (child.type === 'Rule') {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === 'Atrule') {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (child !== children.last) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t}\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? '' : '\\t'\n\tNEWLINE = minify ? '' : '\\n'\n\tSPACE = minify ? '' : ' '\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["NEWLINE","TAB","SPACE","indent","size","repeat","substr","node","css","loc","start","end","str","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","undefined","type","_step","children","_iterator","_createForOfIteratorHelperLoose","done","selector","value","print_selector","print_unknown","last","print_selectorlist","print_block","print_simple_selector","_step2","_iterator2","child","name","_iterator3","_step3","grandchild","nth","a","b","startsWith","prev_type","isEmpty","_step4","_iterator4","print_declaration","print_atrule","toLowerCase","print_prelude","property","test","print_value","trim","print_list","_step5","_iterator5","first","print_function","print_dimension","unit","substr_raw","format","_temp","_ref","_ref$minify","minify","ast","parse","positions","parseAtrulePrelude","parseCustomProperty","parseValue","_step6","_iterator6","print"],"mappings":"grCAIA,IAAIA,EAAU,KACVC,EAAM,KACNC,EAAQ,IAOZ,SAASC,EAAOC,GACf,OAAOH,EAAII,OAAOD,EACnB,CAOA,SAASE,EAAOC,EAAMC,GACrB,IAAIC,EAAMF,EAAKE,IAEf,IAAKA,EAAK,MAAO,GAEjB,IAAIC,EAAQD,EAAIC,MACZC,EAAMF,EAAIE,IACVC,EAAMJ,EAAIK,UAAUH,EAAMI,OAAQH,EAAIG,QAG1C,OAAIJ,EAAMK,OAASJ,EAAII,KACfH,EAIDA,EAAII,QAAQ,OAAQ,IAC5B,CAmBA,SAASC,EAAWV,EAAMC,EAAKU,GAC9B,IAAIC,EACAC,EAAUb,EAAKa,QAC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O,EAAO/B,EAAKU,GAGjCqB,IAAUd,EAASQ,OACtBd,GAAUnB,EAAUA,EAEtB,CAEA,OAAOmB,CACR,CAuBQ8D,CAAMR,EAAKjE,EAAK,EACxB,qBAOgB,SAAOA,GACtB,OAAO4D,EAAO5D,EAAK,CAAEgE,QAAQ,GAC9B"}
1
+ {"version":3,"file":"format.umd.js","sources":["../index.js"],"sourcesContent":["// @ts-expect-error Typing of css-tree is incomplete\nimport parse from 'css-tree/parser'\n\nconst SPACE = ' '\nconst EMPTY_STRING = ''\nconst TYPE_ATRULE = 'Atrule'\nconst TYPE_RULE = 'Rule'\nconst TYPE_BLOCK = 'Block'\nconst TYPE_SELECTORLIST = 'SelectorList'\nconst TYPE_SELECTOR = 'Selector'\nconst TYPE_DECLARATION = 'Declaration'\nconst TYPE_OPERATOR = 'Operator'\n\n// Warning: can be overridden when { minify: true }\nlet NEWLINE = '\\n' // or ''\nlet TAB = '\\t' // or ''\nlet OPTIONAL_SPACE = ' ' // or ''\nlet LAST_SEMICOLON = ';'\n\n/**\n * Indent a string\n * @param {number} size\n * @returns A string with {size} tabs\n */\nfunction indent(size) {\n\treturn TAB.repeat(size)\n}\n\n/**\n * Check if a string contains uppercase characters\n * @param {string} str\n */\nfunction is_uppercase(str) {\n\treturn /[A-Z]/.test(str)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr(node, css) {\n\tlet loc = node.loc\n\n\tif (!loc) return EMPTY_STRING\n\n\tlet start = loc.start\n\tlet end = loc.end\n\tlet str = css.substring(start.offset, end.offset)\n\n\t// Single-line node, most common case\n\tif (start.line === end.line) {\n\t\treturn str\n\t}\n\n\t// Multi-line nodes, less common\n\treturn str.replace(/\\s+/g, SPACE)\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @returns A portion of the CSS\n */\nfunction substr_raw(node, css) {\n\tlet loc = node.loc\n\tif (!loc) return EMPTY_STRING\n\treturn css.substring(loc.start.offset, loc.end.offset)\n}\n\n/**\n * @param {import('css-tree').Rule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Rule\n */\nfunction print_rule(node, css, indent_level) {\n\tlet buffer\n\tlet prelude = node.prelude\n\tlet block = node.block\n\n\tif (prelude.type === TYPE_SELECTORLIST) {\n\t\tbuffer = print_selectorlist(prelude, css, indent_level)\n\t} else {\n\t\t// In case parsing the selector list fails we'll print it as-is\n\t\tbuffer = print_unknown(prelude, css, indent_level)\n\t}\n\n\tif (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').SelectorList} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted SelectorList\n */\nfunction print_selectorlist(node, css, indent_level) {\n\tlet buffer = EMPTY_STRING\n\tlet children = node.children\n\n\tchildren.forEach((selector, item) => {\n\t\tif (selector.type === TYPE_SELECTOR) {\n\t\t\tbuffer += print_selector(selector, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(selector, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += `,` + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector|import('css-tree').PseudoClassSelector} node\n * @param {string} css\n */\nfunction print_simple_selector(node, css) {\n\tlet buffer = EMPTY_STRING\n\n\tif (!node.children) {\n\t\treturn buffer\n\t}\n\n\tnode.children.forEach((child) => {\n\t\tswitch (child.type) {\n\t\t\tcase 'Combinator': {\n\t\t\t\t// putting spaces around `child.name` (+ > ~ or ' '), unless the combinator is ' '\n\t\t\t\tbuffer += SPACE\n\n\t\t\t\tif (child.name !== ' ') {\n\t\t\t\t\tbuffer += child.name + SPACE\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'PseudoClassSelector': {\n\t\t\t\tbuffer += ':'\n\n\t\t\t\t// Special case for `:before` and `:after` which were used in CSS2 and are usually minified\n\t\t\t\t// as `:before` and `:after`, but we want to keep them as `::before` and `::after`\n\t\t\t\tif (child.name === 'before' || child.name === 'after') {\n\t\t\t\t\tbuffer += ':'\n\t\t\t\t}\n\n\t\t\t\tbuffer += child.name\n\n\t\t\t\tif (child.children) {\n\t\t\t\t\tbuffer += '(' + print_simple_selector(child, css) + ')'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase TYPE_SELECTORLIST: {\n\t\t\t\tchild.children.forEach((grandchild, item) => {\n\t\t\t\t\tif (grandchild.type === TYPE_SELECTOR) {\n\t\t\t\t\t\tbuffer += print_simple_selector(grandchild, css)\n\t\t\t\t\t}\n\n\t\t\t\t\tif (item.next) {\n\t\t\t\t\t\tbuffer += ',' + SPACE\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'Nth': {\n\t\t\t\tlet nth = child.nth\n\t\t\t\tif (nth) {\n\t\t\t\t\tif (nth.type === 'AnPlusB') {\n\t\t\t\t\t\tlet a = nth.a\n\t\t\t\t\t\tlet b = nth.b\n\n\t\t\t\t\t\tif (a !== null) {\n\t\t\t\t\t\t\tbuffer += a + 'n'\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (a !== null && b !== null) {\n\t\t\t\t\t\t\tbuffer += SPACE\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (b !== null) {\n\t\t\t\t\t\t\t// When (1n + x) but not (1n - x)\n\t\t\t\t\t\t\tif (a !== null && !b.startsWith('-')) {\n\t\t\t\t\t\t\t\tbuffer += '+' + SPACE\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbuffer += b\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// For odd/even or maybe other identifiers later on\n\t\t\t\t\t\tbuffer += substr(child.nth, css)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (child.selector !== null) {\n\t\t\t\t\t// `of .selector`\n\t\t\t\t\t// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct\n\t\t\t\t\tbuffer += SPACE + 'of' + SPACE + print_simple_selector(child.selector, css)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tbuffer += substr(child, css)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Selector} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Selector\n */\nfunction print_selector(node, css, indent_level) {\n\treturn indent(indent_level) + print_simple_selector(node, css)\n}\n\n/**\n * @param {import('css-tree').Block} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Block\n */\nfunction print_block(node, css, indent_level) {\n\tlet children = node.children\n\tlet buffer = OPTIONAL_SPACE\n\n\tif (children.isEmpty) {\n\t\treturn buffer + '{}'\n\t}\n\n\tbuffer += '{' + NEWLINE\n\n\tindent_level++\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_DECLARATION) {\n\t\t\tbuffer += print_declaration(child, css, indent_level)\n\n\t\t\tif (item.next === null) {\n\t\t\t\tbuffer += LAST_SEMICOLON\n\t\t\t} else {\n\t\t\t\tbuffer += ';'\n\t\t\t}\n\t\t} else {\n\t\t\tif (item.prev !== null && item.prev.data.type === TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\n\t\t\tif (child.type === TYPE_RULE) {\n\t\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t\t} else {\n\t\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t\t}\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE\n\n\t\t\tif (child.type !== TYPE_DECLARATION) {\n\t\t\t\tbuffer += NEWLINE\n\t\t\t}\n\t\t}\n\t})\n\n\tindent_level--\n\n\tbuffer += NEWLINE\n\tbuffer += indent(indent_level) + '}'\n\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Atrule} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Atrule\n */\nfunction print_atrule(node, css, indent_level) {\n\tlet buffer = indent(indent_level) + '@'\n\tlet name = node.name\n\tlet prelude = node.prelude\n\tlet block = node.block\n\tbuffer += is_uppercase(name) ? name.toLowerCase() : name\n\n\t// @font-face has no prelude\n\tif (prelude !== null) {\n\t\tbuffer += SPACE + print_prelude(prelude, css)\n\t}\n\n\tif (block === null) {\n\t\t// `@import url(style.css);` has no block, neither does `@layer layer1;`\n\t\tbuffer += ';'\n\t} else if (block.type === TYPE_BLOCK) {\n\t\tbuffer += print_block(block, css, indent_level)\n\t}\n\n\treturn buffer\n}\n\n/**\n * Pretty-printing atrule preludes takes an insane amount of rules,\n * so we're opting for a couple of 'good-enough' string replacements\n * here to force some nice formatting.\n * Should be OK perf-wise, since the amount of atrules in most\n * stylesheets are limited, so this won't be called too often.\n * @param {import('css-tree').AtrulePrelude | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_prelude(node, css) {\n\tlet buffer = substr(node, css)\n\n\treturn buffer\n\t\t.replace(/\\s*([:,])/g, buffer.includes('selector(') ? '$1' : '$1 ') // force whitespace after colon or comma, except inside `selector()`\n\t\t.replace(/\\s*(=>|<=)\\s*/g, ' $1 ') // force whitespace around => and <=\n\t\t.replace(/(?<!<=)(?<!=>)(?<!<= )([<>])(?![<= ])(?![=> ])(?![ =>])/g, ' $1 ')\n\t\t.replace(/\\s+/g, SPACE) // collapse multiple whitespaces into one\n}\n\n/**\n * @param {import('css-tree').Declaration} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted Declaration\n */\nfunction print_declaration(node, css, indent_level) {\n\tlet property = node.property\n\n\t// Lowercase the property, unless it's a custom property (starts with --)\n\tif (!(property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45)) { // 45 == '-'\n\t\tif (is_uppercase(property)) {\n\t\t\tproperty = property.toLowerCase()\n\t\t}\n\t}\n\n\tlet value = print_value(node.value, css)\n\n\t// Special case for `font` shorthand: remove whitespace around /\n\tif (property === 'font') {\n\t\tvalue = value.replace(/\\s*\\/\\s*/, '/')\n\t}\n\n\treturn indent(indent_level) + property + ':' + OPTIONAL_SPACE + value\n}\n\n/**\n * @param {import('css-tree').List<import('css-tree').CssNode>} children\n * @param {string} css\n */\nfunction print_list(children, css) {\n\tlet buffer = EMPTY_STRING\n\n\tchildren.forEach((node, item) => {\n\t\tif (node.type === 'Identifier') {\n\t\t\tbuffer += node.name\n\t\t} else if (node.type === 'Function') {\n\t\t\tbuffer += print_function(node, css)\n\t\t} else if (node.type === 'Dimension') {\n\t\t\tbuffer += print_dimension(node)\n\t\t} else if (node.type === 'Value') {\n\t\t\t// Values can be inside var() as fallback\n\t\t\t// var(--prop, VALUE)\n\t\t\tbuffer += print_value(node, css)\n\t\t} else if (node.type === TYPE_OPERATOR) {\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/CSS/calc#notes\n\t\t\t// The + and - operators must be surrounded by whitespace\n\t\t\t// Whitespace around other operators is optional\n\n\t\t\t// Trim the operator because CSSTree adds whitespace around it\n\t\t\tlet operator = node.value.trim()\n\t\t\tlet code = operator.charCodeAt(0)\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space before + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else if (code !== 44) { // ,\n\t\t\t\t// Add optional space before operator\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\n\t\t\t// FINALLY, render the operator\n\t\t\tbuffer += operator\n\n\t\t\tif (code === 43 || code === 45) { // + or -\n\t\t\t\t// Add required space after + and - operators\n\t\t\t\tbuffer += SPACE\n\t\t\t} else {\n\t\t\t\t// Add optional space after other operators (like *, /, and ,)\n\t\t\t\tbuffer += OPTIONAL_SPACE\n\t\t\t}\n\t\t} else {\n\t\t\tbuffer += substr(node, css)\n\t\t}\n\n\t\tif (node.type !== TYPE_OPERATOR) {\n\t\t\tif (item.next !== null) {\n\t\t\t\tif (item.next.data.type !== TYPE_OPERATOR) {\n\t\t\t\t\tbuffer += SPACE\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/** @param {import('css-tree').Dimension} node */\nfunction print_dimension(node) {\n\tlet unit = node.unit\n\tlet buffer = node.value\n\tbuffer += is_uppercase(unit) ? unit.toLowerCase() : unit;\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').Value | import('css-tree').Raw} node\n * @param {string} css\n */\nfunction print_value(node, css) {\n\tif (node.type === 'Raw') {\n\t\treturn print_unknown(node, css, 0)\n\t}\n\n\treturn print_list(node.children, css)\n}\n\n/**\n * @param {import('css-tree').FunctionNode} node\n * @param {string} css\n */\nfunction print_function(node, css) {\n\tlet name = node.name\n\tlet buffer = name\n\n\tif (is_uppercase(name)) {\n\t\tbuffer = name.toLowerCase()\n\t}\n\n\tbuffer += '('\n\tbuffer += print_list(node.children, css)\n\tbuffer += ')'\n\treturn buffer\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} indent_level\n * @returns {string} A formatted unknown CSS string\n */\nfunction print_unknown(node, css, indent_level) {\n\treturn indent(indent_level) + substr_raw(node, css).trim()\n}\n\n/**\n * @param {import('css-tree').CssNode} node\n * @param {string} css\n * @param {number} [indent_level=0]\n * @returns {string} A formatted Stylesheet\n */\nfunction print(node, css, indent_level = 0) {\n\tlet buffer = EMPTY_STRING\n\n\t/** @type {import('css-tree').List<import('css-tree').CssNode>} */\n\t// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that\n\tlet children = node.children\n\n\tchildren.forEach((child, item) => {\n\t\tif (child.type === TYPE_RULE) {\n\t\t\tbuffer += print_rule(child, css, indent_level)\n\t\t} else if (child.type === TYPE_ATRULE) {\n\t\t\tbuffer += print_atrule(child, css, indent_level)\n\t\t} else {\n\t\t\tbuffer += print_unknown(child, css, indent_level)\n\t\t}\n\n\t\tif (item.next !== null) {\n\t\t\tbuffer += NEWLINE + NEWLINE\n\t\t}\n\t})\n\n\treturn buffer\n}\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [minify] Whether to minify the CSS or keep it formatted\n *\n * Take a string of CSS (minified or not) and format it with some simple rules\n * @param {string} css The original CSS\n * @param {Options} options\n * @returns {string} The formatted CSS\n */\nexport function format(css, { minify = false } = {}) {\n\t/** @type {import('css-tree').CssNode} */\n\tlet ast = parse(css, {\n\t\tpositions: true,\n\t\tparseAtrulePrelude: false,\n\t\tparseCustomProperty: true,\n\t\tparseValue: true,\n\t})\n\n\tTAB = minify ? EMPTY_STRING : '\\t'\n\tNEWLINE = minify ? EMPTY_STRING : '\\n'\n\tOPTIONAL_SPACE = minify ? EMPTY_STRING : ' '\n\tLAST_SEMICOLON = minify ? EMPTY_STRING : ';'\n\n\treturn print(ast, css, 0)\n}\n\n/**\n * Take a string of CSS and minify it\n * @param {string} css The original CSS\n * @returns {string} The minified CSS\n */\nexport function minify(css) {\n\treturn format(css, { minify: true })\n}\n"],"names":["SPACE","EMPTY_STRING","TYPE_ATRULE","TYPE_RULE","TYPE_BLOCK","TYPE_SELECTORLIST","TYPE_SELECTOR","TYPE_DECLARATION","TYPE_OPERATOR","NEWLINE","TAB","OPTIONAL_SPACE","LAST_SEMICOLON","indent","size","repeat","is_uppercase","str","test","substr","node","css","loc","start","end","substring","offset","line","replace","print_rule","indent_level","buffer","prelude","block","type","children","forEach","selector","item","print_simple_selector","print_selector","print_unknown","next","print_selectorlist","print_block","child","name","grandchild","nth","a","b","startsWith","isEmpty","property","charCodeAt","toLowerCase","value","print_value","print_declaration","prev","data","print_atrule","includes","print_prelude","print_list","print_function","unit","print_dimension","operator","trim","code","substr_raw","format","_temp","_ref$minify","minify","ast","parse","positions","parseAtrulePrelude","parseCustomProperty","parseValue","print"],"mappings":"0XAGMA,EAAQ,IACRC,EA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ED,EAAII,UAAUH,EAAIC,MAAMG,OAAQJ,EAAIE,IAAIE,QAD9BzB,CAElB,CA2Y+BsE,CAAWnD,EAAMC,GAAKgD,MACrD,CAyCgB,SAAAG,EAAOnD,EAAGoD,GAA2B,IAAFC,QAAF,IAAID,EAAJ,CAAA,EAAEA,GAArBE,OAAAA,OAAS,IAAHD,GAAQA,EAEvCE,EAAMC,EAAAA,QAAMxD,EAAK,CACpByD,WAAW,EACXC,oBAAoB,EACpBC,qBAAqB,EACrBC,YAAY,IAQb,OALAvE,EAAMiE,EAAS1E,EAAe,KAC9BQ,EAAUkE,EAAS1E,EAAe,KAClCU,EAAiBgE,EAAS1E,EAAe,IACzCW,EAAiB+D,EAAS1E,EAAe,IA7C1C,SAAemB,EAAMC,EAAKS,QAAAA,IAAAA,IAAAA,EAAe,GACxC,IAAIC,EAAS9B,EAoBb,OAhBemB,EAAKe,SAEXC,QAAQ,SAACS,EAAOP,GAEvBP,GADGc,EAAMX,OAAS/B,EACR0B,EAAWgB,EAAOxB,EAAKS,GACvBe,EAAMX,OAAShC,EACf2D,EAAahB,EAAOxB,EAAKS,GAEzBW,EAAcI,EAAOxB,EAAKS,GAGnB,OAAdQ,EAAKI,OACRX,GAAUtB,EAAUA,EAEtB,GAEOsB,CACR,CAyBQmD,CAAMN,EAAKvD,EAAK,EACxB,qBAOO,SAAgBA,GACtB,OAAOmD,EAAOnD,EAAK,CAAEsD,QAAQ,GAC9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectwallace/format-css",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Fast, small, zero-config library to format CSS with basic rules.",
5
5
  "type": "module",
6
6
  "source": "index.js",