├── index.d.ts ├── CssPosition.d.ts ├── type.d.ts ├── cssTools.js └── cssTools.js.map /index.d.ts: -------------------------------------------------------------------------------- 1 | export { default as parse } from './parse'; 2 | export { default as stringify } from './stringify'; 3 | export * from './type'; 4 | export * from './CssParseError'; 5 | export * from './CssPosition'; 6 | -------------------------------------------------------------------------------- /CssPosition.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Store position information for a node 3 | */ 4 | export default class Position { 5 | start: { 6 | line: number; 7 | column: number; 8 | }; 9 | end: { 10 | line: number; 11 | column: number; 12 | }; 13 | source?: string; 14 | constructor(start: { 15 | line: number; 16 | column: number; 17 | }, end: { 18 | line: number; 19 | column: number; 20 | }, source: string); 21 | } 22 | -------------------------------------------------------------------------------- /type.d.ts: -------------------------------------------------------------------------------- 1 | import CssParseError from './CssParseError'; 2 | import Position from './CssPosition'; 3 | export declare enum CssTypes { 4 | stylesheet = "stylesheet", 5 | rule = "rule", 6 | declaration = "declaration", 7 | comment = "comment", 8 | container = "container", 9 | charset = "charset", 10 | document = "document", 11 | customMedia = "custom-media", 12 | fontFace = "font-face", 13 | host = "host", 14 | import = "import", 15 | keyframes = "keyframes", 16 | keyframe = "keyframe", 17 | layer = "layer", 18 | media = "media", 19 | namespace = "namespace", 20 | page = "page", 21 | supports = "supports" 22 | } 23 | export type CssCommonAST = { 24 | type: CssTypes; 25 | }; 26 | export type CssCommonPositionAST = CssCommonAST & { 27 | position?: Position; 28 | parent?: unknown; 29 | }; 30 | export type CssStylesheetAST = CssCommonAST & { 31 | type: CssTypes.stylesheet; 32 | stylesheet: { 33 | source?: string; 34 | rules: Array; 35 | parsingErrors?: Array; 36 | }; 37 | }; 38 | export type CssRuleAST = CssCommonPositionAST & { 39 | type: CssTypes.rule; 40 | selectors: Array; 41 | declarations: Array; 42 | }; 43 | export type CssDeclarationAST = CssCommonPositionAST & { 44 | type: CssTypes.declaration; 45 | property: string; 46 | value: string; 47 | }; 48 | export type CssCommentAST = CssCommonPositionAST & { 49 | type: CssTypes.comment; 50 | comment: string; 51 | }; 52 | export type CssContainerAST = CssCommonPositionAST & { 53 | type: CssTypes.container; 54 | container: string; 55 | rules: Array; 56 | }; 57 | export type CssCharsetAST = CssCommonPositionAST & { 58 | type: CssTypes.charset; 59 | charset: string; 60 | }; 61 | export type CssCustomMediaAST = CssCommonPositionAST & { 62 | type: CssTypes.customMedia; 63 | name: string; 64 | media: string; 65 | }; 66 | export type CssDocumentAST = CssCommonPositionAST & { 67 | type: CssTypes.document; 68 | document: string; 69 | vendor?: string; 70 | rules: Array; 71 | }; 72 | export type CssFontFaceAST = CssCommonPositionAST & { 73 | type: CssTypes.fontFace; 74 | declarations: Array; 75 | }; 76 | export type CssHostAST = CssCommonPositionAST & { 77 | type: CssTypes.host; 78 | rules: Array; 79 | }; 80 | export type CssImportAST = CssCommonPositionAST & { 81 | type: CssTypes.import; 82 | import: string; 83 | }; 84 | export type CssKeyframesAST = CssCommonPositionAST & { 85 | type: CssTypes.keyframes; 86 | name: string; 87 | vendor?: string; 88 | keyframes: Array; 89 | }; 90 | export type CssKeyframeAST = CssCommonPositionAST & { 91 | type: CssTypes.keyframe; 92 | values: Array; 93 | declarations: Array; 94 | }; 95 | export type CssLayerAST = CssCommonPositionAST & { 96 | type: CssTypes.layer; 97 | layer: string; 98 | rules?: Array; 99 | }; 100 | export type CssMediaAST = CssCommonPositionAST & { 101 | type: CssTypes.media; 102 | media: string; 103 | rules: Array; 104 | }; 105 | export type CssNamespaceAST = CssCommonPositionAST & { 106 | type: CssTypes.namespace; 107 | namespace: string; 108 | }; 109 | export type CssPageAST = CssCommonPositionAST & { 110 | type: CssTypes.page; 111 | selectors: Array; 112 | declarations: Array; 113 | }; 114 | export type CssSupportsAST = CssCommonPositionAST & { 115 | type: CssTypes.supports; 116 | supports: string; 117 | rules: Array; 118 | }; 119 | export type CssAtRuleAST = CssRuleAST | CssCommentAST | CssContainerAST | CssCharsetAST | CssCustomMediaAST | CssDocumentAST | CssFontFaceAST | CssHostAST | CssImportAST | CssKeyframesAST | CssLayerAST | CssMediaAST | CssNamespaceAST | CssPageAST | CssSupportsAST; 120 | export type CssAllNodesAST = CssAtRuleAST | CssStylesheetAST | CssDeclarationAST | CssKeyframeAST; 121 | -------------------------------------------------------------------------------- /cssTools.js: -------------------------------------------------------------------------------- 1 | (()=>{"use strict";var t={831:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});class s extends Error{constructor(t,e,s,i,n){super(t+":"+s+":"+i+": "+e),this.reason=e,this.filename=t,this.line=s,this.column=i,this.source=n}}e.default=s},711:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t,e,s){this.start=t,this.end=e,this.source=s}}},607:function(t,e,s){var i=this&&this.__createBinding||(Object.create?function(t,e,s,i){void 0===i&&(i=s);var n=Object.getOwnPropertyDescriptor(e,s);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[s]}}),Object.defineProperty(t,i,n)}:function(t,e,s,i){void 0===i&&(i=s),t[i]=e[s]}),n=this&&this.__exportStar||function(t,e){for(var s in t)"default"===s||Object.prototype.hasOwnProperty.call(e,s)||i(e,t,s)};Object.defineProperty(e,"__esModule",{value:!0}),e.stringify=e.parse=void 0;var r=s(654);Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return r.default}});var o=s(373);Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return o.default}}),n(s(371),e),n(s(831),e),n(s(711),e)},654:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parse=void 0;const i=s(831),n=s(711),r=s(371),o=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function c(t){return t?t.trim():""}function a(t,e){const s=t&&"string"==typeof t.type,i=s?t:e;for(const e in t){const s=t[e];Array.isArray(s)?s.forEach((t=>{a(t,i)})):s&&"object"==typeof s&&a(s,i)}return s&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:e||null}),t}e.parse=(t,e)=>{e=e||{};let s=1,u=1;function m(){const t={line:s,column:u};return function(i){return i.position=new n.default(t,{line:s,column:u},(null==e?void 0:e.source)||""),g(),i}}const h=[];function p(n){const r=new i.default((null==e?void 0:e.source)||"",n,s,u,t);if(!(null==e?void 0:e.silent))throw r;h.push(r)}function l(){return y(/^{\s*/)}function f(){return y(/^}/)}function d(){let e;const s=[];for(g(),v(s);t.length&&"}"!==t.charAt(0)&&(e=M()||P());)e&&(s.push(e),v(s));return s}function y(e){const i=e.exec(t);if(!i)return;const n=i[0];return function(t){const e=t.match(/\n/g);e&&(s+=e.length);const i=t.lastIndexOf("\n");u=~i?t.length-i:u+t.length}(n),t=t.slice(n.length),i}function g(){y(/^\s*/)}function v(t){let e;for(t=t||[];e=C();)e&&t.push(e);return t}function C(){const e=m();if("/"!==t.charAt(0)||"*"!==t.charAt(1))return;const s=y(/^\/\*[^]*?\*\//);return s?e({type:r.CssTypes.comment,comment:s[0].slice(2,-2)}):p("End of comment missing")}function T(){const t=y(/^([^{]+)/);if(!t)return;const e=c(t[0]).replace(/\/\*[^]*?\*\//gm,"");return-1===e.indexOf(",")?[e]:e.replace(/("|')(?:\\\1|.)*?\1|\(.*?\)/g,(t=>t.replace(/,/g,"‌"))).split(",").map((t=>c(t.replace(/\u200C/g,","))))}function V(){const t=m(),e=y(/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(!e)return;const s=c(e[0]);if(!y(/^:\s*/))return p("property missing ':'");const i=y(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/),n=t({type:r.CssTypes.declaration,property:s.replace(o,""),value:i?c(i[0]).replace(o,""):""});return y(/^[;\s]*/),n}function b(){const t=[];if(!l())return p("missing '{'");let e;for(v(t);e=V();)e&&(t.push(e),v(t));return f()?t:p("missing '}'")}function j(){let t;const e=[],s=m();for(;t=y(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)e.push(t[1]),y(/^,\s*/);if(e.length)return s({type:r.CssTypes.keyframe,values:e,declarations:b()||[]})}const k=w("import"),_=w("charset"),O=w("namespace");function w(t){const e=new RegExp("^@"+t+"\\s*((:?[^;'\"]|\"(?:\\\\\"|[^\"])*?\"|'(?:\\\\'|[^'])*?')+);");return function(){const s=m(),i=y(e);if(!i)return;const n={type:t};return n[t]=i[1].trim(),s(n)}}function M(){if("@"===t[0])return function(){const t=m(),e=y(/^@([-\w]+)?keyframes\s*/);if(!e)return;const s=e[1],i=y(/^([-\w]+)\s*/);if(!i)return p("@keyframes missing name");const n=i[1];if(!l())return p("@keyframes missing '{'");let o,c=v();for(;o=j();)c.push(o),c=c.concat(v());return f()?t({type:r.CssTypes.keyframes,name:n,vendor:s,keyframes:c}):p("@keyframes missing '}'")}()||function(){const t=m(),e=y(/^@media *([^{]+)/);if(!e)return;const s=c(e[1]);if(!l())return p("@media missing '{'");const i=v().concat(d());return f()?t({type:r.CssTypes.media,media:s,rules:i}):p("@media missing '}'")}()||function(){const t=m(),e=y(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(e)return t({type:r.CssTypes.customMedia,name:c(e[1]),media:c(e[2])})}()||function(){const t=m(),e=y(/^@supports *([^{]+)/);if(!e)return;const s=c(e[1]);if(!l())return p("@supports missing '{'");const i=v().concat(d());return f()?t({type:r.CssTypes.supports,supports:s,rules:i}):p("@supports missing '}'")}()||k()||_()||O()||function(){const t=m(),e=y(/^@([-\w]+)?document *([^{]+)/);if(!e)return;const s=c(e[1]),i=c(e[2]);if(!l())return p("@document missing '{'");const n=v().concat(d());return f()?t({type:r.CssTypes.document,document:i,vendor:s,rules:n}):p("@document missing '}'")}()||function(){const t=m();if(!y(/^@page */))return;const e=T()||[];if(!l())return p("@page missing '{'");let s,i=v();for(;s=V();)i.push(s),i=i.concat(v());return f()?t({type:r.CssTypes.page,selectors:e,declarations:i}):p("@page missing '}'")}()||function(){const t=m();if(!y(/^@host\s*/))return;if(!l())return p("@host missing '{'");const e=v().concat(d());return f()?t({type:r.CssTypes.host,rules:e}):p("@host missing '}'")}()||function(){const t=m();if(!y(/^@font-face\s*/))return;if(!l())return p("@font-face missing '{'");let e,s=v();for(;e=V();)s.push(e),s=s.concat(v());return f()?t({type:r.CssTypes.fontFace,declarations:s}):p("@font-face missing '}'")}()||function(){const t=m(),e=y(/^@container *([^{]+)/);if(!e)return;const s=c(e[1]);if(!l())return p("@container missing '{'");const i=v().concat(d());return f()?t({type:r.CssTypes.container,container:s,rules:i}):p("@container missing '}'")}()||function(){const t=m(),e=y(/^@layer *([^{;@]+)/);if(!e)return;const s=c(e[1]);if(!l())return y(/^[;\s]*/),t({type:r.CssTypes.layer,layer:s});const i=v().concat(d());return f()?t({type:r.CssTypes.layer,layer:s,rules:i}):p("@layer missing '}'")}()}function P(){const t=m(),e=T();return e?(v(),t({type:r.CssTypes.rule,selectors:e,declarations:b()||[]})):p("selector missing")}return a(function(){const t=d();return{type:r.CssTypes.stylesheet,stylesheet:{source:null==e?void 0:e.source,rules:t,parsingErrors:h}}}())},e.default=e.parse},854:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=s(371);e.default=class{constructor(t){this.level=0,this.indentation=" ",this.compress=!1,"string"==typeof(null==t?void 0:t.indent)&&(this.indentation=null==t?void 0:t.indent),(null==t?void 0:t.compress)&&(this.compress=!0)}emit(t,e){return t}indent(t){return this.level=this.level||1,t?(this.level+=t,""):Array(this.level).join(this.indentation)}visit(t){switch(t.type){case i.CssTypes.stylesheet:return this.stylesheet(t);case i.CssTypes.rule:return this.rule(t);case i.CssTypes.declaration:return this.declaration(t);case i.CssTypes.comment:return this.comment(t);case i.CssTypes.container:return this.container(t);case i.CssTypes.charset:return this.charset(t);case i.CssTypes.document:return this.document(t);case i.CssTypes.customMedia:return this.customMedia(t);case i.CssTypes.fontFace:return this.fontFace(t);case i.CssTypes.host:return this.host(t);case i.CssTypes.import:return this.import(t);case i.CssTypes.keyframes:return this.keyframes(t);case i.CssTypes.keyframe:return this.keyframe(t);case i.CssTypes.layer:return this.layer(t);case i.CssTypes.media:return this.media(t);case i.CssTypes.namespace:return this.namespace(t);case i.CssTypes.page:return this.page(t);case i.CssTypes.supports:return this.supports(t)}}mapVisit(t,e){let s="";e=e||"";for(let i=0,n=t.length;is+t)).join(",\n"),t.position)+this.emit(" {\n")+this.emit(this.indent(1))+this.mapVisit(e,"\n")+this.emit(this.indent(-1))+this.emit("\n"+this.indent()+"}")}declaration(t){return this.compress?this.emit(t.property+":"+t.value,t.position)+this.emit(";"):this.emit(this.indent())+this.emit(t.property+": "+t.value,t.position)+this.emit(";")}}},373:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});const i=s(854);e.default=(t,e)=>new i.default(e||{}).compile(t)},371:(t,e)=>{var s;Object.defineProperty(e,"__esModule",{value:!0}),e.CssTypes=void 0,(s=e.CssTypes||(e.CssTypes={})).stylesheet="stylesheet",s.rule="rule",s.declaration="declaration",s.comment="comment",s.container="container",s.charset="charset",s.document="document",s.customMedia="custom-media",s.fontFace="font-face",s.host="host",s.import="import",s.keyframes="keyframes",s.keyframe="keyframe",s.layer="layer",s.media="media",s.namespace="namespace",s.page="page",s.supports="supports"}},e={},s=function s(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i].call(r.exports,r,r.exports,s),r.exports}(607);module.exports=s})(); 2 | //# sourceMappingURL=cssTools.js.map -------------------------------------------------------------------------------- /cssTools.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"cssTools.js","mappings":"uFAAA,MAAqBA,UAAsBC,MAOzCC,YACEC,EACAC,EACAC,EACAC,EACAC,GAEAC,MAAML,EAAW,IAAME,EAAS,IAAMC,EAAS,KAAOF,GACtDK,KAAKC,OAASN,EACdK,KAAKN,SAAWA,EAChBM,KAAKE,KAAON,EACZI,KAAKH,OAASA,EACdG,KAAKG,OAASL,CAChB,EApBF,W,+DCGA,gBAKEL,YACEW,EACAC,EACAF,GAEAH,KAAKI,MAAQA,EACbJ,KAAKK,IAAMA,EACX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,GAC1BuG,QAAQrG,E,cCL1B,IAAY2B,E,oEAAAA,EAAA,EAAAA,WAAA,EAAAA,SAAQ,KAClB,wBACA,cACA,4BACA,oBACA,wBACA,oBACA,sBACA,6BACA,uBACA,cACA,kBACA,wBACA,sBACA,gBACA,gBACA,wBACA,cACA,qB,GCpBE2E,EAA2B,CAAC,ECE5BC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaE,QAGrB,IAAIC,EAASP,EAAyBG,GAAY,CAGjDG,QAAS,CAAC,GAOX,OAHAE,EAAoBL,GAAUM,KAAKF,EAAOD,QAASC,EAAQA,EAAOD,QAASJ,GAGpEK,EAAOD,OACf,CCnB0BJ,CAAoB,K","sources":["webpack://@adobe/css-tools/./src/CssParseError.ts","webpack://@adobe/css-tools/./src/CssPosition.ts","webpack://@adobe/css-tools/./src/index.ts","webpack://@adobe/css-tools/./src/parse/index.ts","webpack://@adobe/css-tools/./src/stringify/compiler.ts","webpack://@adobe/css-tools/./src/stringify/index.ts","webpack://@adobe/css-tools/./src/type.ts","webpack://@adobe/css-tools/webpack/bootstrap","webpack://@adobe/css-tools/webpack/startup"],"sourcesContent":["export default class CssParseError extends Error {\n readonly reason: string;\n readonly filename?: string;\n readonly line: number;\n readonly column: number;\n readonly source: string;\n\n constructor(\n filename: string,\n msg: string,\n lineno: number,\n column: number,\n css: string\n ) {\n super(filename + ':' + lineno + ':' + column + ': ' + msg);\n this.reason = msg;\n this.filename = filename;\n this.line = lineno;\n this.column = column;\n this.source = css;\n }\n}\n","/**\n * Store position information for a node\n */\nexport default class Position {\n start: {line: number; column: number};\n end: {line: number; column: number};\n source?: string;\n\n constructor(\n start: {line: number; column: number},\n end: {line: number; column: number},\n source: string\n ) {\n this.start = start;\n this.end = end;\n this.source = source;\n }\n}\n","export {default as parse} from './parse';\nexport {default as stringify} from './stringify';\nexport * from './type';\nexport * from './CssParseError';\nexport * from './CssPosition';\n","import CssParseError from '../CssParseError';\nimport Position from '../CssPosition';\nimport {\n CssAtRuleAST,\n CssCharsetAST,\n CssCommentAST,\n CssCommonPositionAST,\n CssContainerAST,\n CssCustomMediaAST,\n CssDeclarationAST,\n CssDocumentAST,\n CssFontFaceAST,\n CssHostAST,\n CssImportAST,\n CssKeyframeAST,\n CssKeyframesAST,\n CssLayerAST,\n CssMediaAST,\n CssNamespaceAST,\n CssPageAST,\n CssRuleAST,\n CssStylesheetAST,\n CssSupportsAST,\n CssTypes,\n} from '../type';\n\n// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nconst commentre = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nexport const parse = (\n css: string,\n options?: {source?: string; silent?: boolean}\n): CssStylesheetAST => {\n options = options || {};\n\n /**\n * Positional.\n */\n let lineno = 1;\n let column = 1;\n\n /**\n * Update lineno and column based on `str`.\n */\n function updatePosition(str: string) {\n const lines = str.match(/\\n/g);\n if (lines) lineno += lines.length;\n const i = str.lastIndexOf('\\n');\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n */\n function position() {\n const start = {line: lineno, column: column};\n return function (\n node: Omit\n ): T1 {\n (node as T1).position = new Position(\n start,\n {line: lineno, column: column},\n options?.source || ''\n );\n whitespace();\n return node as T1;\n };\n }\n\n /**\n * Error `msg`.\n */\n const errorsList: Array = [];\n\n function error(msg: string) {\n const err = new CssParseError(\n options?.source || '',\n msg,\n lineno,\n column,\n css\n );\n\n if (options?.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Parse stylesheet.\n */\n function stylesheet(): CssStylesheetAST {\n const rulesList = rules();\n\n const result: CssStylesheetAST = {\n type: CssTypes.stylesheet,\n stylesheet: {\n source: options?.source,\n rules: rulesList,\n parsingErrors: errorsList,\n },\n };\n\n return result;\n }\n\n /**\n * Opening brace.\n */\n function open() {\n return match(/^{\\s*/);\n }\n\n /**\n * Closing brace.\n */\n function close() {\n return match(/^}/);\n }\n\n /**\n * Parse ruleset.\n */\n function rules() {\n let node: CssRuleAST | CssAtRuleAST | void;\n const rules: Array = [];\n whitespace();\n comments(rules);\n while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {\n if (node) {\n rules.push(node);\n comments(rules);\n }\n }\n return rules;\n }\n\n /**\n * Match `re` and return captures.\n */\n function match(re: RegExp) {\n const m = re.exec(css);\n if (!m) {\n return;\n }\n const str = m[0];\n updatePosition(str);\n css = css.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(/^\\s*/);\n }\n\n /**\n * Parse comments;\n */\n function comments(\n rules?: Array\n ) {\n let c;\n rules = rules || [];\n while ((c = comment())) {\n if (c) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n */\n function comment(): CssCommentAST | void {\n const pos = position();\n if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {\n return;\n }\n\n const m = match(/^\\/\\*[^]*?\\*\\//);\n if (!m) {\n return error('End of comment missing');\n }\n\n return pos({\n type: CssTypes.comment,\n comment: m[0].slice(2, -2),\n });\n }\n\n /**\n * Parse selector.\n */\n function selector() {\n const m = match(/^([^{]+)/);\n if (!m) {\n return;\n }\n\n // remove comment in selector; [^] is equivalent to [.\\n\\r]\n const res = trim(m[0]).replace(/\\/\\*[^]*?\\*\\//gm, '');\n\n // Optimisation: If there is no ',' no need to split or post-process (this is less costly)\n if (res.indexOf(',') === -1) {\n return [res];\n }\n\n return (\n res\n /**\n * replace ',' by \\u200C for data selector (div[data-lang=\"fr,de,us\"])\n * replace ',' by \\u200C for nthChild and other selector (div:nth-child(2,3,4))\n *\n * Examples:\n * div[data-lang=\"fr,\\\"de,us\"]\n * div[data-lang='fr,\\'de,us']\n * div:matches(.toto, .titi:matches(.toto, .titi))\n *\n * Regex logic:\n * (\"|')(?:\\\\\\1|.)*?\\1 => Handle the \" and '\n * \\(.*?\\) => Handle the ()\n *\n * Optimization 1:\n * No greedy capture (see docs about the difference between .* and .*?)\n *\n * Optimization 2:\n * (\"|')(?:\\\\\\1|.)*?\\1 this use reference to capture group, it work faster.\n */\n .replace(/(\"|')(?:\\\\\\1|.)*?\\1|\\(.*?\\)/g, m => m.replace(/,/g, '\\u200C'))\n // Split the selector by ','\n .split(',')\n // Replace back \\u200C by ','\n .map(s => {\n return trim(s.replace(/\\u200C/g, ','));\n })\n );\n }\n\n /**\n * Parse declaration.\n */\n function declaration(): CssDeclarationAST | void {\n const pos = position();\n\n // prop\n const propMatch = match(/^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/);\n if (!propMatch) {\n return;\n }\n const propValue = trim(propMatch[0]);\n\n // :\n if (!match(/^:\\s*/)) {\n return error(\"property missing ':'\");\n }\n\n // val\n const val = match(/^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/);\n\n const ret = pos({\n type: CssTypes.declaration,\n property: propValue.replace(commentre, ''),\n value: val ? trim(val[0]).replace(commentre, '') : '',\n });\n\n // ;\n match(/^[;\\s]*/);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n */\n function declarations() {\n const decls: Array = [];\n\n if (!open()) {\n return error(\"missing '{'\");\n }\n comments(decls);\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n if (decl) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n if (!close()) {\n return error(\"missing '}'\");\n }\n return decls;\n }\n\n /**\n * Parse keyframe.\n */\n function keyframe() {\n let m;\n const vals = [];\n const pos = position();\n\n while ((m = match(/^((\\d+\\.\\d+|\\.\\d+|\\d+)%?|[a-z]+)\\s*/))) {\n vals.push(m[1]);\n match(/^,\\s*/);\n }\n\n if (!vals.length) {\n return;\n }\n\n return pos({\n type: CssTypes.keyframe,\n values: vals,\n declarations: declarations() || [],\n });\n }\n\n /**\n * Parse keyframes.\n */\n function atkeyframes(): CssKeyframesAST | void {\n const pos = position();\n const m1 = match(/^@([-\\w]+)?keyframes\\s*/);\n\n if (!m1) {\n return;\n }\n const vendor = m1[1];\n\n // identifier\n const m2 = match(/^([-\\w]+)\\s*/);\n if (!m2) {\n return error('@keyframes missing name');\n }\n const name = m2[1];\n\n if (!open()) {\n return error(\"@keyframes missing '{'\");\n }\n\n let frame;\n let frames: Array = comments();\n while ((frame = keyframe())) {\n frames.push(frame);\n frames = frames.concat(comments());\n }\n\n if (!close()) {\n return error(\"@keyframes missing '}'\");\n }\n\n return pos({\n type: CssTypes.keyframes,\n name: name,\n vendor: vendor,\n keyframes: frames,\n });\n }\n\n /**\n * Parse supports.\n */\n function atsupports(): CssSupportsAST | void {\n const pos = position();\n const m = match(/^@supports *([^{]+)/);\n\n if (!m) {\n return;\n }\n const supports = trim(m[1]);\n\n if (!open()) {\n return error(\"@supports missing '{'\");\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(\"@supports missing '}'\");\n }\n\n return pos({\n type: CssTypes.supports,\n supports: supports,\n rules: style,\n });\n }\n\n /**\n * Parse host.\n */\n function athost() {\n const pos = position();\n const m = match(/^@host\\s*/);\n\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(\"@host missing '{'\");\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(\"@host missing '}'\");\n }\n\n return pos({\n type: CssTypes.host,\n rules: style,\n });\n }\n\n /**\n * Parse container.\n */\n function atcontainer(): CssContainerAST | void {\n const pos = position();\n const m = match(/^@container *([^{]+)/);\n\n if (!m) {\n return;\n }\n const container = trim(m[1]);\n\n if (!open()) {\n return error(\"@container missing '{'\");\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(\"@container missing '}'\");\n }\n\n return pos({\n type: CssTypes.container,\n container: container,\n rules: style,\n });\n }\n\n /**\n * Parse container.\n */\n function atlayer(): CssLayerAST | void {\n const pos = position();\n const m = match(/^@layer *([^{;@]+)/);\n\n if (!m) {\n return;\n }\n const layer = trim(m[1]);\n\n if (!open()) {\n match(/^[;\\s]*/);\n return pos({\n type: CssTypes.layer,\n layer: layer,\n });\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(\"@layer missing '}'\");\n }\n\n return pos({\n type: CssTypes.layer,\n layer: layer,\n rules: style,\n });\n }\n\n /**\n * Parse media.\n */\n function atmedia(): CssMediaAST | void {\n const pos = position();\n const m = match(/^@media *([^{]+)/);\n\n if (!m) {\n return;\n }\n const media = trim(m[1]);\n\n if (!open()) {\n return error(\"@media missing '{'\");\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(\"@media missing '}'\");\n }\n\n return pos({\n type: CssTypes.media,\n media: media,\n rules: style,\n });\n }\n\n /**\n * Parse custom-media.\n */\n function atcustommedia(): CssCustomMediaAST | void {\n const pos = position();\n const m = match(/^@custom-media\\s+(--[^\\s]+)\\s*([^{;]+);/);\n if (!m) {\n return;\n }\n\n return pos({\n type: CssTypes.customMedia,\n name: trim(m[1]),\n media: trim(m[2]),\n });\n }\n\n /**\n * Parse paged media.\n */\n function atpage(): CssPageAST | void {\n const pos = position();\n const m = match(/^@page */);\n if (!m) {\n return;\n }\n\n const sel = selector() || [];\n\n if (!open()) {\n return error(\"@page missing '{'\");\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(\"@page missing '}'\");\n }\n\n return pos({\n type: CssTypes.page,\n selectors: sel,\n declarations: decls,\n });\n }\n\n /**\n * Parse document.\n */\n function atdocument(): CssDocumentAST | void {\n const pos = position();\n const m = match(/^@([-\\w]+)?document *([^{]+)/);\n if (!m) {\n return;\n }\n\n const vendor = trim(m[1]);\n const doc = trim(m[2]);\n\n if (!open()) {\n return error(\"@document missing '{'\");\n }\n\n const style = comments().concat(rules());\n\n if (!close()) {\n return error(\"@document missing '}'\");\n }\n\n return pos({\n type: CssTypes.document,\n document: doc,\n vendor: vendor,\n rules: style,\n });\n }\n\n /**\n * Parse font-face.\n */\n function atfontface(): CssFontFaceAST | void {\n const pos = position();\n const m = match(/^@font-face\\s*/);\n if (!m) {\n return;\n }\n\n if (!open()) {\n return error(\"@font-face missing '{'\");\n }\n let decls = comments();\n\n // declarations\n let decl;\n while ((decl = declaration())) {\n decls.push(decl);\n decls = decls.concat(comments());\n }\n\n if (!close()) {\n return error(\"@font-face missing '}'\");\n }\n\n return pos({\n type: CssTypes.fontFace,\n declarations: decls,\n });\n }\n\n /**\n * Parse import\n */\n const atimport = _compileAtrule('import');\n\n /**\n * Parse charset\n */\n const atcharset = _compileAtrule('charset');\n\n /**\n * Parse namespace\n */\n const atnamespace = _compileAtrule('namespace');\n\n /**\n * Parse non-block at-rules\n */\n function _compileAtrule(\n name: string\n ): () => T1 | void {\n const re = new RegExp(\n '^@' +\n name +\n '\\\\s*((:?[^;\\'\"]|\"(?:\\\\\\\\\"|[^\"])*?\"|\\'(?:\\\\\\\\\\'|[^\\'])*?\\')+);'\n );\n\n // ^@import\\s*([^;\"']|(\"|')(?:\\\\\\2|.)*?\\2)+;\n\n return function (): T1 | void {\n const pos = position();\n const m = match(re);\n if (!m) {\n return;\n }\n const ret: Record = {type: name};\n ret[name] = m[1].trim();\n return pos(ret as unknown as T1) as T1;\n };\n }\n\n /**\n * Parse at rule.\n */\n function atrule(): CssAtRuleAST | void {\n if (css[0] !== '@') {\n return;\n }\n\n return (\n atkeyframes() ||\n atmedia() ||\n atcustommedia() ||\n atsupports() ||\n atimport() ||\n atcharset() ||\n atnamespace() ||\n atdocument() ||\n atpage() ||\n athost() ||\n atfontface() ||\n atcontainer() ||\n atlayer()\n );\n }\n\n /**\n * Parse rule.\n */\n function rule() {\n const pos = position();\n const sel = selector();\n\n if (!sel) {\n return error('selector missing');\n }\n comments();\n\n return pos({\n type: CssTypes.rule,\n selectors: sel,\n declarations: declarations() || [],\n });\n }\n\n return addParent(stylesheet());\n};\n\n/**\n * Trim `str`.\n */\nfunction trim(str: string) {\n return str ? str.trim() : '';\n}\n\n/**\n * Adds non-enumerable parent node reference to each node.\n */\nfunction addParent(obj: T1, parent?: unknown): T1 {\n const isNode = obj && typeof obj.type === 'string';\n const childParent = isNode ? obj : parent;\n\n for (const k in obj) {\n const value = obj[k];\n if (Array.isArray(value)) {\n value.forEach(v => {\n addParent(v, childParent);\n });\n } else if (value && typeof value === 'object') {\n addParent(value, childParent);\n }\n }\n\n if (isNode) {\n Object.defineProperty(obj, 'parent', {\n configurable: true,\n writable: true,\n enumerable: false,\n value: parent || null,\n });\n }\n\n return obj;\n}\n\nexport default parse;\n","import {\n CssAllNodesAST,\n CssCharsetAST,\n CssCommentAST,\n CssCommonPositionAST,\n CssContainerAST,\n CssCustomMediaAST,\n CssDeclarationAST,\n CssDocumentAST,\n CssFontFaceAST,\n CssHostAST,\n CssImportAST,\n CssKeyframeAST,\n CssKeyframesAST,\n CssLayerAST,\n CssMediaAST,\n CssNamespaceAST,\n CssPageAST,\n CssRuleAST,\n CssStylesheetAST,\n CssSupportsAST,\n CssTypes,\n} from '../type';\n\nclass Compiler {\n level = 0;\n indentation = ' ';\n compress = false;\n\n constructor(options?: {indent?: string; compress?: boolean}) {\n if (typeof options?.indent === 'string') {\n this.indentation = options?.indent;\n }\n if (options?.compress) {\n this.compress = true;\n }\n }\n\n // We disable no-unused-vars for _position. We keep position for potential reintroduction of source-map\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n emit(str: string, _position?: CssCommonPositionAST['position']) {\n return str;\n }\n\n /**\n * Increase, decrease or return current indentation.\n */\n indent(level?: number) {\n this.level = this.level || 1;\n\n if (level) {\n this.level += level;\n return '';\n }\n\n return Array(this.level).join(this.indentation);\n }\n\n visit(node: CssAllNodesAST): string {\n switch (node.type) {\n case CssTypes.stylesheet:\n return this.stylesheet(node);\n case CssTypes.rule:\n return this.rule(node);\n case CssTypes.declaration:\n return this.declaration(node);\n case CssTypes.comment:\n return this.comment(node);\n case CssTypes.container:\n return this.container(node);\n case CssTypes.charset:\n return this.charset(node);\n case CssTypes.document:\n return this.document(node);\n case CssTypes.customMedia:\n return this.customMedia(node);\n case CssTypes.fontFace:\n return this.fontFace(node);\n case CssTypes.host:\n return this.host(node);\n case CssTypes.import:\n return this.import(node);\n case CssTypes.keyframes:\n return this.keyframes(node);\n case CssTypes.keyframe:\n return this.keyframe(node);\n case CssTypes.layer:\n return this.layer(node);\n case CssTypes.media:\n return this.media(node);\n case CssTypes.namespace:\n return this.namespace(node);\n case CssTypes.page:\n return this.page(node);\n case CssTypes.supports:\n return this.supports(node);\n }\n }\n\n mapVisit(nodes: Array, delim?: string) {\n let buf = '';\n delim = delim || '';\n\n for (let i = 0, length = nodes.length; i < length; i++) {\n buf += this.visit(nodes[i]);\n if (delim && i < length - 1) {\n buf += this.emit(delim);\n }\n }\n\n return buf;\n }\n\n compile(node: CssStylesheetAST) {\n if (this.compress) {\n return node.stylesheet.rules.map(this.visit, this).join('');\n }\n\n return this.stylesheet(node);\n }\n\n /**\n * Visit stylesheet node.\n */\n stylesheet(node: CssStylesheetAST) {\n return this.mapVisit(node.stylesheet.rules, '\\n\\n');\n }\n\n /**\n * Visit comment node.\n */\n comment(node: CssCommentAST) {\n if (this.compress) {\n return this.emit('', node.position);\n }\n return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);\n }\n\n /**\n * Visit container node.\n */\n container(node: CssContainerAST) {\n if (this.compress) {\n return (\n this.emit('@container ' + node.container, node.position) +\n this.emit('{') +\n this.mapVisit(node.rules) +\n this.emit('}')\n );\n }\n return (\n this.emit(this.indent() + '@container ' + node.container, node.position) +\n this.emit(' {\\n' + this.indent(1)) +\n this.mapVisit(node.rules, '\\n\\n') +\n this.emit('\\n' + this.indent(-1) + this.indent() + '}')\n );\n }\n\n /**\n * Visit container node.\n */\n layer(node: CssLayerAST) {\n if (this.compress) {\n return (\n this.emit('@layer ' + node.layer, node.position) +\n (node.rules\n ? this.emit('{') +\n this.mapVisit(node.rules) +\n this.emit('}')\n : ';')\n );\n }\n return (\n this.emit(this.indent() + '@layer ' + node.layer, node.position) +\n (node.rules\n ? this.emit(' {\\n' + this.indent(1)) +\n this.mapVisit(node.rules, '\\n\\n') +\n this.emit('\\n' + this.indent(-1) + this.indent() + '}')\n : ';')\n );\n }\n\n /**\n * Visit import node.\n */\n import(node: CssImportAST) {\n return this.emit('@import ' + node.import + ';', node.position);\n }\n\n /**\n * Visit media node.\n */\n media(node: CssMediaAST) {\n if (this.compress) {\n return (\n this.emit('@media ' + node.media, node.position) +\n this.emit('{') +\n this.mapVisit(node.rules) +\n this.emit('}')\n );\n }\n return (\n this.emit(this.indent() + '@media ' + node.media, node.position) +\n this.emit(' {\\n' + this.indent(1)) +\n this.mapVisit(node.rules, '\\n\\n') +\n this.emit('\\n' + this.indent(-1) + this.indent() + '}')\n );\n }\n\n /**\n * Visit document node.\n */\n document(node: CssDocumentAST) {\n const doc = '@' + (node.vendor || '') + 'document ' + node.document;\n if (this.compress) {\n return (\n this.emit(doc, node.position) +\n this.emit('{') +\n this.mapVisit(node.rules) +\n this.emit('}')\n );\n }\n return (\n this.emit(doc, node.position) +\n this.emit(' ' + ' {\\n' + this.indent(1)) +\n this.mapVisit(node.rules, '\\n\\n') +\n this.emit(this.indent(-1) + '\\n}')\n );\n }\n\n /**\n * Visit charset node.\n */\n charset(node: CssCharsetAST) {\n return this.emit('@charset ' + node.charset + ';', node.position);\n }\n\n /**\n * Visit namespace node.\n */\n namespace(node: CssNamespaceAST) {\n return this.emit('@namespace ' + node.namespace + ';', node.position);\n }\n\n /**\n * Visit supports node.\n */\n supports(node: CssSupportsAST) {\n if (this.compress) {\n return (\n this.emit('@supports ' + node.supports, node.position) +\n this.emit('{') +\n this.mapVisit(node.rules) +\n this.emit('}')\n );\n }\n return (\n this.emit(this.indent() + '@supports ' + node.supports, node.position) +\n this.emit(' {\\n' + this.indent(1)) +\n this.mapVisit(node.rules, '\\n\\n') +\n this.emit('\\n' + this.indent(-1) + this.indent() + '}')\n );\n }\n\n /**\n * Visit keyframes node.\n */\n keyframes(node: CssKeyframesAST) {\n if (this.compress) {\n return (\n this.emit(\n '@' + (node.vendor || '') + 'keyframes ' + node.name,\n node.position\n ) +\n this.emit('{') +\n this.mapVisit(node.keyframes) +\n this.emit('}')\n );\n }\n return (\n this.emit(\n '@' + (node.vendor || '') + 'keyframes ' + node.name,\n node.position\n ) +\n this.emit(' {\\n' + this.indent(1)) +\n this.mapVisit(node.keyframes, '\\n') +\n this.emit(this.indent(-1) + '}')\n );\n }\n\n /**\n * Visit keyframe node.\n */\n keyframe(node: CssKeyframeAST) {\n const decls = node.declarations;\n if (this.compress) {\n return (\n this.emit(node.values.join(','), node.position) +\n this.emit('{') +\n this.mapVisit(decls) +\n this.emit('}')\n );\n }\n\n return (\n this.emit(this.indent()) +\n this.emit(node.values.join(', '), node.position) +\n this.emit(' {\\n' + this.indent(1)) +\n this.mapVisit(decls, '\\n') +\n this.emit(this.indent(-1) + '\\n' + this.indent() + '}\\n')\n );\n }\n\n /**\n * Visit page node.\n */\n page(node: CssPageAST) {\n if (this.compress) {\n const sel = node.selectors.length ? node.selectors.join(', ') : '';\n\n return (\n this.emit('@page ' + sel, node.position) +\n this.emit('{') +\n this.mapVisit(node.declarations) +\n this.emit('}')\n );\n }\n const sel = node.selectors.length ? node.selectors.join(', ') + ' ' : '';\n\n return (\n this.emit('@page ' + sel, node.position) +\n this.emit('{\\n') +\n this.emit(this.indent(1)) +\n this.mapVisit(node.declarations, '\\n') +\n this.emit(this.indent(-1)) +\n this.emit('\\n}')\n );\n }\n\n /**\n * Visit font-face node.\n */\n fontFace(node: CssFontFaceAST) {\n if (this.compress) {\n return (\n this.emit('@font-face', node.position) +\n this.emit('{') +\n this.mapVisit(node.declarations) +\n this.emit('}')\n );\n }\n return (\n this.emit('@font-face ', node.position) +\n this.emit('{\\n') +\n this.emit(this.indent(1)) +\n this.mapVisit(node.declarations, '\\n') +\n this.emit(this.indent(-1)) +\n this.emit('\\n}')\n );\n }\n\n /**\n * Visit host node.\n */\n host(node: CssHostAST) {\n if (this.compress) {\n return (\n this.emit('@host', node.position) +\n this.emit('{') +\n this.mapVisit(node.rules) +\n this.emit('}')\n );\n }\n return (\n this.emit('@host', node.position) +\n this.emit(' {\\n' + this.indent(1)) +\n this.mapVisit(node.rules, '\\n\\n') +\n this.emit(this.indent(-1) + '\\n}')\n );\n }\n\n /**\n * Visit custom-media node.\n */\n customMedia(node: CssCustomMediaAST) {\n return this.emit(\n '@custom-media ' + node.name + ' ' + node.media + ';',\n node.position\n );\n }\n\n /**\n * Visit rule node.\n */\n rule(node: CssRuleAST) {\n const decls = node.declarations;\n if (!decls.length) {\n return '';\n }\n\n if (this.compress) {\n return (\n this.emit(node.selectors.join(','), node.position) +\n this.emit('{') +\n this.mapVisit(decls) +\n this.emit('}')\n );\n }\n const indent = this.indent();\n\n return (\n this.emit(\n node.selectors\n .map(s => {\n return indent + s;\n })\n .join(',\\n'),\n node.position\n ) +\n this.emit(' {\\n') +\n this.emit(this.indent(1)) +\n this.mapVisit(decls, '\\n') +\n this.emit(this.indent(-1)) +\n this.emit('\\n' + this.indent() + '}')\n );\n }\n\n /**\n * Visit declaration node.\n */\n declaration(node: CssDeclarationAST) {\n if (this.compress) {\n return (\n this.emit(node.property + ':' + node.value, node.position) +\n this.emit(';')\n );\n }\n return (\n this.emit(this.indent()) +\n this.emit(node.property + ': ' + node.value, node.position) +\n this.emit(';')\n );\n }\n}\n\nexport default Compiler;\n","import {CssStylesheetAST} from '../type';\nimport Compiler from './compiler';\n\nexport default (\n node: CssStylesheetAST,\n options?: ConstructorParameters[0]\n) => {\n const compiler = new Compiler(options || {});\n return compiler.compile(node);\n};\n","import CssParseError from './CssParseError';\nimport Position from './CssPosition';\n\nexport enum CssTypes {\n stylesheet = 'stylesheet',\n rule = 'rule',\n declaration = 'declaration',\n comment = 'comment',\n container = 'container',\n charset = 'charset',\n document = 'document',\n customMedia = 'custom-media',\n fontFace = 'font-face',\n host = 'host',\n import = 'import',\n keyframes = 'keyframes',\n keyframe = 'keyframe',\n layer = 'layer',\n media = 'media',\n namespace = 'namespace',\n page = 'page',\n supports = 'supports',\n}\n\nexport type CssCommonAST = {\n type: CssTypes;\n};\n\nexport type CssCommonPositionAST = CssCommonAST & {\n position?: Position;\n parent?: unknown;\n};\n\nexport type CssStylesheetAST = CssCommonAST & {\n type: CssTypes.stylesheet;\n stylesheet: {\n source?: string;\n rules: Array;\n parsingErrors?: Array;\n };\n};\n\nexport type CssRuleAST = CssCommonPositionAST & {\n type: CssTypes.rule;\n selectors: Array;\n declarations: Array;\n};\n\nexport type CssDeclarationAST = CssCommonPositionAST & {\n type: CssTypes.declaration;\n property: string;\n value: string;\n};\n\nexport type CssCommentAST = CssCommonPositionAST & {\n type: CssTypes.comment;\n comment: string;\n};\nexport type CssContainerAST = CssCommonPositionAST & {\n type: CssTypes.container;\n container: string;\n rules: Array;\n};\n\nexport type CssCharsetAST = CssCommonPositionAST & {\n type: CssTypes.charset;\n charset: string;\n};\nexport type CssCustomMediaAST = CssCommonPositionAST & {\n type: CssTypes.customMedia;\n name: string;\n media: string;\n};\nexport type CssDocumentAST = CssCommonPositionAST & {\n type: CssTypes.document;\n document: string;\n vendor?: string;\n rules: Array;\n};\nexport type CssFontFaceAST = CssCommonPositionAST & {\n type: CssTypes.fontFace;\n declarations: Array;\n};\nexport type CssHostAST = CssCommonPositionAST & {\n type: CssTypes.host;\n rules: Array;\n};\nexport type CssImportAST = CssCommonPositionAST & {\n type: CssTypes.import;\n import: string;\n};\nexport type CssKeyframesAST = CssCommonPositionAST & {\n type: CssTypes.keyframes;\n name: string;\n vendor?: string;\n keyframes: Array;\n};\nexport type CssKeyframeAST = CssCommonPositionAST & {\n type: CssTypes.keyframe;\n values: Array;\n declarations: Array;\n};\nexport type CssLayerAST = CssCommonPositionAST & {\n type: CssTypes.layer;\n layer: string;\n rules?: Array;\n};\nexport type CssMediaAST = CssCommonPositionAST & {\n type: CssTypes.media;\n media: string;\n rules: Array;\n};\nexport type CssNamespaceAST = CssCommonPositionAST & {\n type: CssTypes.namespace;\n namespace: string;\n};\nexport type CssPageAST = CssCommonPositionAST & {\n type: CssTypes.page;\n selectors: Array;\n declarations: Array;\n};\nexport type CssSupportsAST = CssCommonPositionAST & {\n type: CssTypes.supports;\n supports: string;\n rules: Array;\n};\n\nexport type CssAtRuleAST =\n | CssRuleAST\n | CssCommentAST\n | CssContainerAST\n | CssCharsetAST\n | CssCustomMediaAST\n | CssDocumentAST\n | CssFontFaceAST\n | CssHostAST\n | CssImportAST\n | CssKeyframesAST\n | CssLayerAST\n | CssMediaAST\n | CssNamespaceAST\n | CssPageAST\n | CssSupportsAST;\n\nexport type CssAllNodesAST =\n | CssAtRuleAST\n | CssStylesheetAST\n | CssDeclarationAST\n | CssKeyframeAST;\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(607);\n"],"names":["CssParseError","Error","constructor","filename","msg","lineno","column","css","super","this","reason","line","source","start","end","default","commentre","trim","str","addParent","obj","parent","isNode","type","childParent","k","value","Array","isArray","forEach","v","Object","defineProperty","configurable","writable","enumerable","parse","options","position","node","whitespace","errorsList","error","err","silent","push","open","match","close","rules","comments","length","charAt","atrule","rule","re","m","exec","lines","i","lastIndexOf","updatePosition","slice","c","comment","pos","CssTypes","selector","res","replace","indexOf","split","map","s","declaration","propMatch","propValue","val","ret","property","declarations","decls","decl","keyframe","vals","values","atimport","_compileAtrule","atcharset","atnamespace","name","RegExp","m1","vendor","m2","frame","frames","concat","keyframes","atkeyframes","media","style","atmedia","customMedia","atcustommedia","supports","atsupports","doc","document","atdocument","sel","page","selectors","atpage","host","athost","fontFace","atfontface","container","atcontainer","layer","atlayer","rulesList","stylesheet","parsingErrors","level","indentation","compress","indent","emit","_position","join","visit","charset","import","namespace","mapVisit","nodes","delim","buf","compile","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","call"],"sourceRoot":""} --------------------------------------------------------------------------------