(model: Component, opts: CssGeneratorBuildOptionsProps = {})
| 89 | } |
| 90 | |
| 91 | build(model: Component, opts: CssGeneratorBuildOptionsProps = {}) { |
| 92 | const { json } = opts; |
| 93 | const em = opts.em; |
| 94 | const cssc = opts.cssc || em?.Css; |
| 95 | this.em = em; |
| 96 | this.compCls = []; |
| 97 | this.ids = []; |
| 98 | this.model = model; |
| 99 | const codeJson: CssRule[] = []; |
| 100 | let code = model ? this.buildFromModel(model, opts) : ''; |
| 101 | const clearStyles = isUndefined(opts.clearStyles) && em ? em.getConfig().clearStyles : opts.clearStyles; |
| 102 | |
| 103 | if (cssc) { |
| 104 | let rules: CssRules | CssRule[] = opts.rules || cssc.getAll(); |
| 105 | const atRules: AtRules = {}; |
| 106 | const dump: CssRule[] = []; |
| 107 | |
| 108 | if (opts.onlyMatched && model && hasWin()) { |
| 109 | rules = this.matchedRules(model, rules); |
| 110 | } |
| 111 | |
| 112 | rules.forEach((rule) => { |
| 113 | if (rule.isNested()) return; |
| 114 | |
| 115 | const atRule = rule.getAtRule(); |
| 116 | |
| 117 | if (atRule) { |
| 118 | const mRules = atRules[atRule]; |
| 119 | if (mRules) { |
| 120 | mRules.push(rule); |
| 121 | } else { |
| 122 | atRules[atRule] = [rule]; |
| 123 | } |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | const res = this.buildFromRule(rule, dump, opts); |
| 128 | |
| 129 | if (json) { |
| 130 | codeJson.push(res as CssRule); |
| 131 | } else { |
| 132 | code += res; |
| 133 | } |
| 134 | }); |
| 135 | |
| 136 | this.sortMediaObject(atRules).forEach((item) => { |
| 137 | let rulesStr = ''; |
| 138 | const atRule = item.key; |
| 139 | const mRules = item.value; |
| 140 | |
| 141 | mRules.forEach((rule) => { |
| 142 | if (rule.isNested()) return; |
| 143 | |
| 144 | const ruleStr = this.buildFromRule(rule, dump, opts); |
| 145 | |
| 146 | if (rule.get('singleAtRule')) { |
| 147 | code += `${atRule}{${ruleStr}}`; |
| 148 | } else { |
nothing calls this directly
no test coverage detected