@master/css 2.0.0-rc.69 → 2.0.0-rc.70

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.
Files changed (200) hide show
  1. package/README.md +6 -8
  2. package/dist/index.d.ts +2 -40
  3. package/dist/index.mjs +1 -42
  4. package/package.json +1 -1
  5. package/src/base.css +1 -0
  6. package/src/index.css +1 -0
  7. package/src/theme.css +1 -0
  8. package/src/utilities.css +1 -0
  9. package/src/variants.css +1 -0
  10. package/dist/_virtual/_commonjsHelpers.cjs +0 -10
  11. package/dist/_virtual/_commonjsHelpers.mjs +0 -7
  12. package/dist/_virtual/css-escape.cjs +0 -5
  13. package/dist/_virtual/css-escape.mjs +0 -3
  14. package/dist/animation-rule.cjs +0 -24
  15. package/dist/animation-rule.d.ts +0 -11
  16. package/dist/animation-rule.mjs +0 -22
  17. package/dist/bin/index.cjs +0 -11
  18. package/dist/bin/index.d.ts +0 -1
  19. package/dist/bin/index.mjs +0 -9
  20. package/dist/common.cjs +0 -208
  21. package/dist/common.d.ts +0 -40
  22. package/dist/common.mjs +0 -180
  23. package/dist/config/animations.cjs +0 -113
  24. package/dist/config/animations.d.ts +0 -110
  25. package/dist/config/animations.mjs +0 -111
  26. package/dist/config/at.cjs +0 -19
  27. package/dist/config/at.d.ts +0 -16
  28. package/dist/config/at.mjs +0 -17
  29. package/dist/config/functions.cjs +0 -141
  30. package/dist/config/functions.d.ts +0 -138
  31. package/dist/config/functions.mjs +0 -139
  32. package/dist/config/index.cjs +0 -40
  33. package/dist/config/index.d.ts +0 -12
  34. package/dist/config/index.mjs +0 -29
  35. package/dist/config/modes.cjs +0 -312
  36. package/dist/config/modes.d.ts +0 -309
  37. package/dist/config/modes.mjs +0 -310
  38. package/dist/config/rules.cjs +0 -2277
  39. package/dist/config/rules.d.ts +0 -1485
  40. package/dist/config/rules.mjs +0 -2275
  41. package/dist/config/screens.cjs +0 -17
  42. package/dist/config/screens.d.ts +0 -14
  43. package/dist/config/screens.mjs +0 -15
  44. package/dist/config/selectors.cjs +0 -25
  45. package/dist/config/selectors.d.ts +0 -22
  46. package/dist/config/selectors.mjs +0 -23
  47. package/dist/config/utilities.cjs +0 -446
  48. package/dist/config/utilities.d.ts +0 -443
  49. package/dist/config/utilities.mjs +0 -444
  50. package/dist/config/variables.cjs +0 -99
  51. package/dist/config/variables.d.ts +0 -423
  52. package/dist/config/variables.mjs +0 -97
  53. package/dist/core.cjs +0 -674
  54. package/dist/core.d.ts +0 -128
  55. package/dist/core.mjs +0 -672
  56. package/dist/create.cjs +0 -10
  57. package/dist/create.d.ts +0 -3
  58. package/dist/create.mjs +0 -8
  59. package/dist/declarers/core.group.cjs +0 -99
  60. package/dist/declarers/core.group.d.ts +0 -2
  61. package/dist/declarers/core.group.mjs +0 -97
  62. package/dist/declarers/core.variable.cjs +0 -9
  63. package/dist/declarers/core.variable.d.ts +0 -4
  64. package/dist/declarers/core.variable.mjs +0 -7
  65. package/dist/declarers/index.cjs +0 -13
  66. package/dist/declarers/index.d.ts +0 -10
  67. package/dist/declarers/index.mjs +0 -11
  68. package/dist/declarers/pair.cjs +0 -12
  69. package/dist/declarers/pair.d.ts +0 -4
  70. package/dist/declarers/pair.mjs +0 -10
  71. package/dist/factories/with-syntax-layer.cjs +0 -83
  72. package/dist/factories/with-syntax-layer.d.ts +0 -26
  73. package/dist/factories/with-syntax-layer.mjs +0 -81
  74. package/dist/function-transformers/core.calc.cjs +0 -225
  75. package/dist/function-transformers/core.calc.d.ts +0 -2
  76. package/dist/function-transformers/core.calc.mjs +0 -223
  77. package/dist/function-transformers/core.variable.cjs +0 -23
  78. package/dist/function-transformers/core.variable.d.ts +0 -7
  79. package/dist/function-transformers/core.variable.mjs +0 -21
  80. package/dist/function-transformers/index.cjs +0 -11
  81. package/dist/function-transformers/index.d.ts +0 -8
  82. package/dist/function-transformers/index.mjs +0 -9
  83. package/dist/index.cjs +0 -118
  84. package/dist/layer.cjs +0 -52
  85. package/dist/layer.d.ts +0 -16
  86. package/dist/layer.mjs +0 -50
  87. package/dist/non-layer.cjs +0 -55
  88. package/dist/non-layer.d.ts +0 -12
  89. package/dist/non-layer.mjs +0 -53
  90. package/dist/polyfills/css-escape.cjs +0 -9
  91. package/dist/polyfills/css-escape.d.ts +0 -0
  92. package/dist/polyfills/css-escape.mjs +0 -7
  93. package/dist/polyfills/css-escape2.cjs +0 -76
  94. package/dist/polyfills/css-escape2.mjs +0 -74
  95. package/dist/register-global.cjs +0 -7
  96. package/dist/register-global.d.ts +0 -5
  97. package/dist/register-global.mjs +0 -5
  98. package/dist/rule.cjs +0 -16
  99. package/dist/rule.d.ts +0 -7
  100. package/dist/rule.mjs +0 -14
  101. package/dist/shared/utils/css-escape.cjs +0 -56
  102. package/dist/shared/utils/css-escape.mjs +0 -54
  103. package/dist/shared/utils/find-native-css-rule-index.cjs +0 -12
  104. package/dist/shared/utils/find-native-css-rule-index.mjs +0 -10
  105. package/dist/syntax-layer.cjs +0 -8
  106. package/dist/syntax-layer.d.ts +0 -18
  107. package/dist/syntax-layer.mjs +0 -6
  108. package/dist/syntax-rule-type.cjs +0 -27
  109. package/dist/syntax-rule-type.d.ts +0 -28
  110. package/dist/syntax-rule-type.mjs +0 -25
  111. package/dist/syntax-rule.cjs +0 -506
  112. package/dist/syntax-rule.d.ts +0 -44
  113. package/dist/syntax-rule.mjs +0 -504
  114. package/dist/transformers/auto-fill-solid.cjs +0 -31
  115. package/dist/transformers/auto-fill-solid.d.ts +0 -2
  116. package/dist/transformers/auto-fill-solid.mjs +0 -29
  117. package/dist/transformers/index.cjs +0 -9
  118. package/dist/transformers/index.d.ts +0 -6
  119. package/dist/transformers/index.mjs +0 -7
  120. package/dist/types/common.cjs +0 -2
  121. package/dist/types/common.d.ts +0 -1
  122. package/dist/types/common.mjs +0 -1
  123. package/dist/types/config.cjs +0 -2
  124. package/dist/types/config.d.ts +0 -79
  125. package/dist/types/config.mjs +0 -1
  126. package/dist/types/syntax.cjs +0 -2
  127. package/dist/types/syntax.d.ts +0 -89
  128. package/dist/types/syntax.mjs +0 -1
  129. package/dist/utils/compare-rule-priority.cjs +0 -143
  130. package/dist/utils/compare-rule-priority.d.ts +0 -7
  131. package/dist/utils/compare-rule-priority.mjs +0 -138
  132. package/dist/utils/equal-at-rules.cjs +0 -22
  133. package/dist/utils/equal-at-rules.d.ts +0 -2
  134. package/dist/utils/equal-at-rules.mjs +0 -20
  135. package/dist/utils/equal-declarations.cjs +0 -10
  136. package/dist/utils/equal-declarations.d.ts +0 -2
  137. package/dist/utils/equal-declarations.mjs +0 -8
  138. package/dist/utils/equal-selectors.cjs +0 -69
  139. package/dist/utils/equal-selectors.d.ts +0 -2
  140. package/dist/utils/equal-selectors.mjs +0 -67
  141. package/dist/utils/equal-variants.cjs +0 -10
  142. package/dist/utils/equal-variants.d.ts +0 -2
  143. package/dist/utils/equal-variants.mjs +0 -8
  144. package/dist/utils/extend-config.cjs +0 -97
  145. package/dist/utils/extend-config.d.ts +0 -11
  146. package/dist/utils/extend-config.mjs +0 -95
  147. package/dist/utils/flatten-meta-object.cjs +0 -38
  148. package/dist/utils/flatten-meta-object.d.ts +0 -13
  149. package/dist/utils/flatten-meta-object.mjs +0 -36
  150. package/dist/utils/flatten-object.cjs +0 -19
  151. package/dist/utils/flatten-object.d.ts +0 -1
  152. package/dist/utils/flatten-object.mjs +0 -17
  153. package/dist/utils/generate-at.cjs +0 -30
  154. package/dist/utils/generate-at.d.ts +0 -2
  155. package/dist/utils/generate-at.mjs +0 -28
  156. package/dist/utils/generate-css.cjs +0 -13
  157. package/dist/utils/generate-css.d.ts +0 -1
  158. package/dist/utils/generate-css.mjs +0 -11
  159. package/dist/utils/generate-selector.cjs +0 -50
  160. package/dist/utils/generate-selector.d.ts +0 -2
  161. package/dist/utils/generate-selector.mjs +0 -48
  162. package/dist/utils/get-single-at-number-rule-node.cjs +0 -9
  163. package/dist/utils/get-single-at-number-rule-node.d.ts +0 -2
  164. package/dist/utils/get-single-at-number-rule-node.mjs +0 -7
  165. package/dist/utils/hex-to-rgb.cjs +0 -30
  166. package/dist/utils/hex-to-rgb.d.ts +0 -1
  167. package/dist/utils/hex-to-rgb.mjs +0 -28
  168. package/dist/utils/is-core-rule.cjs +0 -9
  169. package/dist/utils/is-core-rule.d.ts +0 -1
  170. package/dist/utils/is-core-rule.mjs +0 -7
  171. package/dist/utils/minify-extended-config.cjs +0 -64
  172. package/dist/utils/minify-extended-config.d.ts +0 -9
  173. package/dist/utils/minify-extended-config.mjs +0 -62
  174. package/dist/utils/nest-meta-object.cjs +0 -25
  175. package/dist/utils/nest-meta-object.d.ts +0 -7
  176. package/dist/utils/nest-meta-object.mjs +0 -23
  177. package/dist/utils/parse-at.cjs +0 -156
  178. package/dist/utils/parse-at.d.ts +0 -39
  179. package/dist/utils/parse-at.mjs +0 -154
  180. package/dist/utils/parse-pair.cjs +0 -48
  181. package/dist/utils/parse-pair.d.ts +0 -8
  182. package/dist/utils/parse-pair.mjs +0 -46
  183. package/dist/utils/parse-selector.cjs +0 -114
  184. package/dist/utils/parse-selector.d.ts +0 -19
  185. package/dist/utils/parse-selector.mjs +0 -112
  186. package/dist/utils/parse-value.cjs +0 -39
  187. package/dist/utils/parse-value.d.ts +0 -2
  188. package/dist/utils/parse-value.mjs +0 -37
  189. package/dist/utils/replace-char-outside-quotes.cjs +0 -21
  190. package/dist/utils/replace-char-outside-quotes.d.ts +0 -1
  191. package/dist/utils/replace-char-outside-quotes.mjs +0 -19
  192. package/dist/utils/sort-readable-classes.cjs +0 -86
  193. package/dist/utils/sort-readable-classes.d.ts +0 -7
  194. package/dist/utils/sort-readable-classes.mjs +0 -84
  195. package/dist/utils/split-char-outside-quotes.cjs +0 -29
  196. package/dist/utils/split-char-outside-quotes.d.ts +0 -1
  197. package/dist/utils/split-char-outside-quotes.mjs +0 -27
  198. package/dist/variable-rule.cjs +0 -92
  199. package/dist/variable-rule.d.ts +0 -33
  200. package/dist/variable-rule.mjs +0 -87
@@ -1,504 +0,0 @@
1
- import cssEscape from './shared/utils/css-escape.mjs';
2
- import SyntaxRuleType from './syntax-rule-type.mjs';
3
- import { AT_IDENTIFIERS, VALUE_DELIMITERS, BASE_UNIT_REGEX } from './common.mjs';
4
- import parseValue from './utils/parse-value.mjs';
5
- import parseAt from './utils/parse-at.mjs';
6
- import generateAt from './utils/generate-at.mjs';
7
- import parseSelector from './utils/parse-selector.mjs';
8
- import generateSelector from './utils/generate-selector.mjs';
9
- import { calcRulePriority } from './utils/compare-rule-priority.mjs';
10
- import declarers from './declarers/index.mjs';
11
- import transformers from './transformers/index.mjs';
12
- import functionTransformers from './function-transformers/index.mjs';
13
-
14
- class SyntaxRule {
15
- name;
16
- css;
17
- registeredSyntax;
18
- fixedClass;
19
- native;
20
- atRules;
21
- priority;
22
- type = SyntaxRuleType.Normal;
23
- declarations;
24
- layer;
25
- valid = true;
26
- animationNames;
27
- variableNames;
28
- constructor(name, css, registeredSyntax, fixedClass, mode){
29
- this.name = name;
30
- this.css = css;
31
- this.registeredSyntax = registeredSyntax;
32
- this.fixedClass = fixedClass;
33
- this.mode = mode;
34
- this.layer = css.generalLayer;
35
- Object.assign(this, registeredSyntax);
36
- const { id, definition } = registeredSyntax;
37
- const { declarer, transformer, type, unit, sign } = definition;
38
- this.type = type;
39
- // 1. value / selectorToken
40
- let stateToken;
41
- if (this.type === SyntaxRuleType.Utility) {
42
- stateToken = name.slice(id.length - 1);
43
- } else {
44
- let valueToken;
45
- if (sign && name.startsWith(sign)) {
46
- valueToken = name.slice(1);
47
- } else if (id.endsWith('()')) {
48
- valueToken = name;
49
- } else if (id === 'group') {
50
- valueToken = name;
51
- } else {
52
- const indexOfColon = name.indexOf(':');
53
- this.keyToken = name.slice(0, indexOfColon + 1);
54
- valueToken = name.slice(indexOfColon + 1);
55
- }
56
- this.valueComponents = [];
57
- const parsedValueIndex = this.parseValues(this.valueComponents, 0, valueToken, unit, '', undefined, false, definition.includeAnimations ? Array.from(this.css.animations.keys()) : []);
58
- this.valueToken = valueToken.slice(0, parsedValueIndex);
59
- stateToken = valueToken.slice(parsedValueIndex);
60
- }
61
- // 2. !important
62
- if (stateToken[0] === '!') {
63
- this.important = true;
64
- stateToken = stateToken.slice(1);
65
- }
66
- this.stateToken = stateToken;
67
- // 4. suffix selector
68
- const stateTokens = stateToken.split('@');
69
- const suffixSelector = stateTokens[0];
70
- if (suffixSelector) {
71
- this.selectorNodes = parseSelector(suffixSelector, css);
72
- }
73
- // 5. atTokens
74
- for(let i = 1; i < stateTokens.length; i++){
75
- const atToken = stateTokens[i];
76
- if (css.config.modes?.[atToken]) {
77
- this.mode = atToken;
78
- continue;
79
- }
80
- this.atToken = (this.atToken || '') + '@' + atToken;
81
- const atRule = parseAt(atToken, css);
82
- const targetNodes = this.atRules?.[atRule.id];
83
- if (targetNodes) {
84
- targetNodes.push(...atRule.nodes);
85
- } else {
86
- this.atRules = {
87
- ...this.atRules,
88
- [atRule.id]: atRule.nodes
89
- };
90
- }
91
- }
92
- if (this.mode && css.config.modeTrigger === 'media') {
93
- const atComp = {
94
- name: 'prefers-color-scheme',
95
- value: this.mode
96
- };
97
- if (this.atRules?.media) {
98
- this.atRules.media.push(atComp);
99
- } else {
100
- this.atRules = {
101
- media: [
102
- atComp
103
- ]
104
- };
105
- }
106
- }
107
- if (this.fixedClass) {
108
- this.layer = css.componentsLayer;
109
- } else {
110
- const onlyNode = this.atRules?.layer?.length === 1 && this.atRules.layer[0];
111
- if (onlyNode) {
112
- if (onlyNode.value === 'base') {
113
- this.layer = css.baseLayer;
114
- this.atRules.layer = undefined;
115
- } else if (onlyNode.value === 'preset') {
116
- this.layer = css.presetLayer;
117
- this.atRules.layer = undefined;
118
- }
119
- }
120
- }
121
- // 7. value
122
- let newValue;
123
- if (this.valueComponents) {
124
- if (transformer) {
125
- if (typeof transformer === 'string') {
126
- const transform = transformers[transformer];
127
- this.valueComponents = transform.call(this, this.valueComponents);
128
- } else {
129
- const [name, data] = transformer;
130
- const transform = transformers[name];
131
- this.valueComponents = transform.call(this, this.valueComponents, data);
132
- }
133
- }
134
- newValue = this.resolveValue(this.valueComponents, unit, [], false);
135
- if (definition.declarations) {
136
- const declarations = {};
137
- if (Array.isArray(definition.declarations)) {
138
- for (const property of definition.declarations){
139
- declarations[property] = newValue;
140
- }
141
- } else {
142
- for(const propertyName in definition.declarations){
143
- const propertyValue = definition.declarations[propertyName];
144
- declarations[propertyName] = propertyValue === undefined ? newValue : Array.isArray(propertyValue) ? propertyValue.map((v)=>v === undefined ? newValue : v).join('') : propertyValue;
145
- }
146
- }
147
- this.declarations = declarations;
148
- } else if (declarer) {
149
- if (typeof declarer === 'string') {
150
- const declare = declarers[declarer];
151
- this.declarations = declare.call(this, newValue, this.valueComponents);
152
- } else {
153
- const [name, data] = declarer;
154
- const declare = declarers[name];
155
- this.declarations = declare.call(this, newValue, this.valueComponents, data);
156
- }
157
- } else if (id) {
158
- this.declarations = {
159
- [id]: newValue
160
- };
161
- }
162
- } else {
163
- this.declarations = definition.declarations;
164
- }
165
- if (!Object.entries(this.declarations ?? {}).length) {
166
- this.valid = false;
167
- } else {
168
- for(const propertyName in this.declarations){
169
- if (this.css.animations && (propertyName === 'animation' || propertyName === 'animation-name')) {
170
- const propertyValue = this.declarations[propertyName];
171
- if (!propertyValue) continue;
172
- const rawValues = propertyValue.split(' ');
173
- for (const rawValue of rawValues){
174
- if (this.css.animations.has(rawValue)) {
175
- if (!this.animationNames) {
176
- this.animationNames = new Set([
177
- rawValue
178
- ]);
179
- } else {
180
- this.animationNames.add(rawValue);
181
- }
182
- continue;
183
- }
184
- }
185
- }
186
- }
187
- this.priority = calcRulePriority(this);
188
- }
189
- }
190
- get text() {
191
- if (!this.valid) return '';
192
- const propertiesText = [];
193
- for(const propertyName in this.declarations){
194
- const propertyValue = this.declarations[propertyName];
195
- const propertyText = propertyName + ':' + String(propertyValue);
196
- propertiesText.push(propertyText + ((this.important || this.css.config.important) && !propertyText.endsWith('!important') ? '!important' : ''));
197
- }
198
- let text = this.selectorText + '{' + propertiesText.join(';') + '}';
199
- if (this.atRules !== undefined) AT_IDENTIFIERS.forEach((id)=>{
200
- const nodes = this.atRules?.[id];
201
- if (!nodes) return;
202
- text = generateAt({
203
- id,
204
- nodes
205
- }) + '{' + text + '}';
206
- });
207
- return text;
208
- }
209
- get selectorText() {
210
- let pre = '';
211
- if (this.css.config.scope) {
212
- pre = this.css.config.scope + ' ' + pre;
213
- }
214
- if (this.mode) {
215
- const modeSelector = this.css.getModeSelector(this.mode);
216
- if (modeSelector) {
217
- pre = modeSelector + ' ' + pre;
218
- }
219
- }
220
- const body = pre + '.' + cssEscape(this.fixedClass ?? this.name);
221
- return this.selectorNodes ? generateSelector(this.selectorNodes, body) : body;
222
- }
223
- resolveValue = (valueComponents, unit, bypassVariableNames, bypassParsing)=>{
224
- const { functions } = this.css.config;
225
- let currentValue = '';
226
- for (const eachValueComponent of valueComponents){
227
- switch(eachValueComponent.type){
228
- case 'function':
229
- const functionDefinition = functions && functions[eachValueComponent.name];
230
- const fnTransformer = functionDefinition?.transformer;
231
- if (fnTransformer && !eachValueComponent.bypassTransform) {
232
- const resolvedValue = this.resolveValue(eachValueComponent.children, functionDefinition.unit ?? unit, bypassVariableNames, bypassParsing || eachValueComponent.name === 'calc');
233
- let result;
234
- if (typeof fnTransformer === 'string') {
235
- const fnTransform = functionTransformers[fnTransformer];
236
- result = fnTransform.call(this, resolvedValue, bypassVariableNames);
237
- } else {
238
- const [name, data] = fnTransformer;
239
- const fnTransform = functionTransformers[name];
240
- result = fnTransform.call(this, resolvedValue, bypassVariableNames, data);
241
- }
242
- currentValue += eachValueComponent.token = eachValueComponent.text = typeof result === 'string' ? result : this.resolveValue(result, functionDefinition?.unit ?? unit, bypassVariableNames, bypassParsing);
243
- } else {
244
- currentValue += eachValueComponent.token = eachValueComponent.text = eachValueComponent.name + eachValueComponent.symbol + this.resolveValue(eachValueComponent.children, functionDefinition?.unit ?? unit, bypassVariableNames, bypassParsing) + VALUE_DELIMITERS[eachValueComponent.symbol];
245
- }
246
- break;
247
- // todo: 應挪到 parseValues 階段處理才能支援 variables: { x: 'calc(20vw-30px)' } 這種情況,並且解析上可能會比較合理、精簡
248
- case 'variable':
249
- const variable = this.css.variables.get(eachValueComponent.name);
250
- if (variable) {
251
- const handleVariable = (normalHandler, varHandler)=>{
252
- if (variable.modes) {
253
- if (this.mode) {
254
- const themeVariable = variable.modes[this.mode] ?? variable;
255
- if (themeVariable?.value) {
256
- normalHandler(themeVariable);
257
- }
258
- } else {
259
- if (this.variableNames) {
260
- this.variableNames.add(eachValueComponent.name);
261
- } else {
262
- this.variableNames = new Set([
263
- eachValueComponent.name
264
- ]);
265
- }
266
- varHandler();
267
- }
268
- } else {
269
- normalHandler(variable);
270
- }
271
- };
272
- switch(variable.type){
273
- case 'string':
274
- handleVariable((variable)=>{
275
- const valueComponents = [];
276
- this.parseValues(valueComponents, 0, variable.value, unit, '', undefined, bypassParsing, [
277
- ...bypassVariableNames,
278
- eachValueComponent.name
279
- ]);
280
- currentValue += eachValueComponent.text = this.resolveValue(valueComponents, unit, [
281
- ...bypassVariableNames,
282
- eachValueComponent.name
283
- ], bypassParsing);
284
- }, ()=>{
285
- currentValue += eachValueComponent.text = `var(--${eachValueComponent.name})`;
286
- });
287
- break;
288
- case 'number':
289
- handleVariable((variable)=>{
290
- if (bypassParsing) {
291
- currentValue += eachValueComponent.text = String(variable.value);
292
- } else {
293
- const valueComponent = this.parseValue(variable.value, unit);
294
- currentValue += eachValueComponent.text = valueComponent.value + (valueComponent.unit ?? '');
295
- }
296
- }, ()=>{
297
- currentValue += eachValueComponent.text = unit ? `calc(var(--${eachValueComponent.name}) / 16 * 1rem)` : `var(--${eachValueComponent.name})`;
298
- });
299
- break;
300
- case 'color':
301
- let alpha = eachValueComponent.alpha;
302
- handleVariable((variable)=>{
303
- const colorVariable = variable;
304
- alpha = (alpha || 1) * (colorVariable.alpha || 1);
305
- if (alpha < 1) {
306
- currentValue += eachValueComponent.text = `${colorVariable.space}(${colorVariable.value}/${alpha})`;
307
- } else {
308
- currentValue += eachValueComponent.text = `${colorVariable.space}(${colorVariable.value})`;
309
- }
310
- }, ()=>{
311
- if (alpha !== undefined) {
312
- // use color-mix
313
- currentValue += eachValueComponent.text = `color-mix(in oklab,var(--${eachValueComponent.name}) ${Number(alpha) * 100}%,transparent)`;
314
- } else {
315
- currentValue += eachValueComponent.text = `var(--${eachValueComponent.name})`;
316
- }
317
- });
318
- break;
319
- }
320
- } else {
321
- currentValue += eachValueComponent.text = `var(--${eachValueComponent.name}${eachValueComponent.fallback ? ',' + eachValueComponent.fallback : ''})`;
322
- }
323
- break;
324
- case 'separator':
325
- currentValue += eachValueComponent.text ? eachValueComponent.text : eachValueComponent.text = eachValueComponent.value;
326
- break;
327
- case 'number':
328
- currentValue += eachValueComponent.text = eachValueComponent.value + (eachValueComponent.unit || '');
329
- break;
330
- default:
331
- currentValue += eachValueComponent.text = eachValueComponent.value;
332
- break;
333
- }
334
- }
335
- return currentValue;
336
- };
337
- parseValues = (currentValueComponents, i, value, unit, endSymbol, parentFunctionName, bypassParsing = false, bypassVariableNames = [])=>{
338
- const root = parentFunctionName === undefined;
339
- const isVarFunction = !root && (parentFunctionName.endsWith('$') || parentFunctionName.endsWith('var'));
340
- const checkIsString = (value)=>value === '\'' || value === '"';
341
- const isString = checkIsString(endSymbol);
342
- const separators = [
343
- ','
344
- ];
345
- if (this.definition.separators?.length) {
346
- separators.push(...this.definition.separators);
347
- }
348
- let currentValue = '';
349
- const parse = ()=>{
350
- if (currentValue) {
351
- let handled = false;
352
- if (!isVarFunction || currentValueComponents.length) {
353
- const handleVariable = (variableName, alpha)=>{
354
- const globalVariableValue = this.css.variables.get(variableName);
355
- const variable = this.variables?.get(variableName) || globalVariableValue;
356
- if (variable) {
357
- const name = variable.name ?? variableName;
358
- if (!bypassVariableNames.includes(name)) {
359
- handled = true;
360
- const valueComponent = {
361
- type: 'variable',
362
- name,
363
- variable: this.css.variables.get(name),
364
- token: currentValue
365
- };
366
- if (alpha) valueComponent.alpha = Number(alpha);
367
- currentValueComponents.push(valueComponent);
368
- }
369
- }
370
- };
371
- if (/^\$[a-zA-Z0-9-]+(?:\/[^\/]+)?$/.test(currentValue)) {
372
- const [raw, alpha] = currentValue.slice(1).split('/');
373
- handleVariable(raw, alpha);
374
- } else {
375
- handleVariable(currentValue);
376
- if (!handled) {
377
- const [colorName, alpha] = currentValue.split('/');
378
- handleVariable(colorName, alpha);
379
- }
380
- }
381
- }
382
- if (!handled) {
383
- if (!isVarFunction) {
384
- const result = BASE_UNIT_REGEX.exec(currentValue);
385
- if (result) {
386
- currentValue = String(+result[1] * (this.css.config.baseUnit ?? 1));
387
- }
388
- }
389
- if (bypassParsing) {
390
- currentValueComponents.push({
391
- type: 'string',
392
- value: currentValue,
393
- token: currentValue
394
- });
395
- } else {
396
- const parsedValue = this.parseValue(currentValue, unit);
397
- currentValueComponents.push({
398
- ...parsedValue,
399
- token: currentValue
400
- });
401
- }
402
- }
403
- currentValue = '';
404
- }
405
- };
406
- for(; i < value.length; i++){
407
- const val = value[i];
408
- if (val === endSymbol) {
409
- if (isString) {
410
- let count = 0;
411
- for(let j = currentValue.length - 1;; j--){
412
- if (currentValue[j] !== '\\') break;
413
- count++;
414
- }
415
- if (count % 2) {
416
- currentValue += val;
417
- continue;
418
- } else {
419
- parse();
420
- }
421
- } else {
422
- parse();
423
- }
424
- return i;
425
- } else if (!isString && val in VALUE_DELIMITERS) {
426
- const functionName = currentValue;
427
- const newValueComponent = {
428
- type: 'function',
429
- name: functionName,
430
- symbol: val,
431
- children: [],
432
- token: ''
433
- };
434
- currentValueComponents.push(newValueComponent);
435
- currentValue = '';
436
- const functionDefinition = val === '(' ? this.css.config.functions?.[functionName] : undefined;
437
- i = this.parseValues(newValueComponent.children, ++i, value, functionDefinition?.unit ?? unit, VALUE_DELIMITERS[val], functionName || parentFunctionName || '', bypassParsing || functionName === 'calc');
438
- } else if ((val === '|' || val === ' ') && endSymbol !== '}' && (!isString || parentFunctionName === 'path')) {
439
- parse();
440
- currentValueComponents.push({
441
- type: 'separator',
442
- value: ' ',
443
- token: val
444
- });
445
- } else {
446
- if (!isString) {
447
- if (val === '.') {
448
- if (isNaN(+value[i + 1])) {
449
- if (root) break;
450
- } else if (value[i - 1] === '-') {
451
- currentValue += '0';
452
- }
453
- } else if (separators.includes(val)) {
454
- parse();
455
- currentValueComponents.push({
456
- type: 'separator',
457
- value: val,
458
- text: (val === ',' ? '' : ' ') + val + (val === ',' ? '' : ' '),
459
- token: val
460
- });
461
- continue;
462
- } else if (root && (val === '#' && (currentValue || currentValueComponents.length && currentValueComponents[currentValueComponents.length - 1]['type'] !== 'separator') || [
463
- '!',
464
- '*',
465
- '>',
466
- '+',
467
- '~',
468
- ':',
469
- '[',
470
- '@',
471
- '_'
472
- ].includes(val))) {
473
- break;
474
- }
475
- }
476
- currentValue += val;
477
- }
478
- }
479
- parse();
480
- return i;
481
- };
482
- parseValue(token, unit = this.definition.unit) {
483
- const parsed = parseValue(token, unit, this.css.config.rootSize);
484
- // exclude like `aspect:1/2` from being parsed as 50%
485
- if (this.definition.unit && parsed.type === 'string') {
486
- // 1/2 → 50%
487
- if (/^\d+\/\d+$/.test(parsed.value)) {
488
- const [numerator, denominator] = parsed.value.split('/').map(Number);
489
- return {
490
- token,
491
- value: numerator / denominator * 100,
492
- unit: '%',
493
- type: 'number'
494
- };
495
- }
496
- }
497
- return parsed;
498
- }
499
- get key() {
500
- return (this.fixedClass ? this.fixedClass + ' ' : '') + this.name;
501
- }
502
- }
503
-
504
- export { SyntaxRule };
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var common = require('../common.cjs');
4
-
5
- function autoFillSolid(valueComponents) {
6
- if (valueComponents.length < 2) return valueComponents;
7
- let styleIncluded = false;
8
- let varIncluded = false;
9
- for (const valueComponent of valueComponents){
10
- if (valueComponent.type === 'string' && common.BORDER_STYLE_VALUES.includes(valueComponent.value) || valueComponent.type === 'variable' && common.BORDER_STYLE_VALUES.includes(String(valueComponent.variable?.value))) {
11
- styleIncluded = true;
12
- }
13
- if (valueComponent.type === 'function' && valueComponent.name === 'var') {
14
- varIncluded = true;
15
- }
16
- }
17
- if (!styleIncluded && !varIncluded) {
18
- valueComponents.push({
19
- type: 'separator',
20
- value: ' ',
21
- token: '|'
22
- }, {
23
- type: 'string',
24
- value: 'solid',
25
- token: 'solid'
26
- });
27
- }
28
- return valueComponents;
29
- }
30
-
31
- module.exports = autoFillSolid;
@@ -1,2 +0,0 @@
1
- import { ValueComponent } from '../types/syntax';
2
- export default function autoFillSolid(valueComponents: ValueComponent[]): ValueComponent[];
@@ -1,29 +0,0 @@
1
- import { BORDER_STYLE_VALUES } from '../common.mjs';
2
-
3
- function autoFillSolid(valueComponents) {
4
- if (valueComponents.length < 2) return valueComponents;
5
- let styleIncluded = false;
6
- let varIncluded = false;
7
- for (const valueComponent of valueComponents){
8
- if (valueComponent.type === 'string' && BORDER_STYLE_VALUES.includes(valueComponent.value) || valueComponent.type === 'variable' && BORDER_STYLE_VALUES.includes(String(valueComponent.variable?.value))) {
9
- styleIncluded = true;
10
- }
11
- if (valueComponent.type === 'function' && valueComponent.name === 'var') {
12
- varIncluded = true;
13
- }
14
- }
15
- if (!styleIncluded && !varIncluded) {
16
- valueComponents.push({
17
- type: 'separator',
18
- value: ' ',
19
- token: '|'
20
- }, {
21
- type: 'string',
22
- value: 'solid',
23
- token: 'solid'
24
- });
25
- }
26
- return valueComponents;
27
- }
28
-
29
- export { autoFillSolid as default };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var autoFillSolid = require('./auto-fill-solid.cjs');
4
-
5
- const transformers = {
6
- 'auto-fill-solid': autoFillSolid
7
- };
8
-
9
- module.exports = transformers;
@@ -1,6 +0,0 @@
1
- import autoFillSolid from './auto-fill-solid';
2
- declare const transformers: {
3
- 'auto-fill-solid': typeof autoFillSolid;
4
- };
5
- export default transformers;
6
- export type TransformerNames = keyof typeof transformers;
@@ -1,7 +0,0 @@
1
- import autoFillSolid from './auto-fill-solid.mjs';
2
-
3
- const transformers = {
4
- 'auto-fill-solid': autoFillSolid
5
- };
6
-
7
- export { transformers as default };
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
@@ -1 +0,0 @@
1
- export type Vendors = 'webkit' | 'moz' | 'ms' | 'o';
@@ -1 +0,0 @@
1
-
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-