@master/css 2.0.0-rc.60 → 2.0.0-rc.62

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 (122) hide show
  1. package/dist/animation-rule.cjs +24 -0
  2. package/dist/animation-rule.d.ts +11 -0
  3. package/dist/animation-rule.mjs +22 -0
  4. package/dist/common.cjs +50 -1
  5. package/dist/common.d.ts +14 -0
  6. package/dist/common.mjs +45 -2
  7. package/dist/config/at.cjs +13 -10
  8. package/dist/config/at.d.ts +4 -1
  9. package/dist/config/at.mjs +13 -10
  10. package/dist/config/index.cjs +3 -0
  11. package/dist/config/index.d.ts +2 -1
  12. package/dist/config/index.mjs +3 -1
  13. package/dist/config/modes.d.ts +4 -2
  14. package/dist/config/rules.cjs +28 -46
  15. package/dist/config/rules.d.ts +4 -2
  16. package/dist/config/rules.mjs +28 -46
  17. package/dist/config/screens.cjs +17 -0
  18. package/dist/config/screens.d.ts +14 -0
  19. package/dist/config/screens.mjs +15 -0
  20. package/dist/config/selectors.cjs +11 -15
  21. package/dist/config/selectors.d.ts +10 -8
  22. package/dist/config/selectors.mjs +11 -15
  23. package/dist/config/utilities.cjs +3 -0
  24. package/dist/config/utilities.d.ts +3 -0
  25. package/dist/config/utilities.mjs +3 -0
  26. package/dist/config/variables.cjs +0 -13
  27. package/dist/config/variables.d.ts +0 -13
  28. package/dist/config/variables.mjs +0 -13
  29. package/dist/core.cjs +438 -476
  30. package/dist/core.d.ts +14 -6
  31. package/dist/core.mjs +438 -476
  32. package/dist/factories/with-syntax-layer.cjs +37 -260
  33. package/dist/factories/with-syntax-layer.mjs +37 -260
  34. package/dist/index.cjs +38 -12
  35. package/dist/index.d.ts +19 -7
  36. package/dist/index.mjs +17 -7
  37. package/dist/layer.cjs +11 -7
  38. package/dist/layer.d.ts +4 -3
  39. package/dist/layer.mjs +11 -7
  40. package/dist/non-layer.cjs +10 -17
  41. package/dist/non-layer.d.ts +1 -1
  42. package/dist/non-layer.mjs +10 -17
  43. package/dist/rule.cjs +4 -6
  44. package/dist/rule.d.ts +3 -10
  45. package/dist/rule.mjs +4 -6
  46. package/dist/syntax-rule-type.cjs +7 -8
  47. package/dist/syntax-rule-type.d.ts +7 -7
  48. package/dist/syntax-rule-type.mjs +7 -8
  49. package/dist/syntax-rule.cjs +125 -315
  50. package/dist/syntax-rule.d.ts +18 -21
  51. package/dist/syntax-rule.mjs +126 -316
  52. package/dist/types/common.d.ts +2 -0
  53. package/dist/types/config.d.ts +12 -7
  54. package/dist/types/syntax.d.ts +5 -24
  55. package/dist/utils/compare-rule-priority.cjs +143 -0
  56. package/dist/utils/compare-rule-priority.d.ts +7 -0
  57. package/dist/utils/compare-rule-priority.mjs +138 -0
  58. package/dist/utils/equal-at-rules.cjs +22 -0
  59. package/dist/utils/equal-at-rules.d.ts +2 -0
  60. package/dist/utils/equal-at-rules.mjs +20 -0
  61. package/dist/utils/equal-declarations.cjs +10 -0
  62. package/dist/utils/equal-declarations.d.ts +2 -0
  63. package/dist/utils/equal-declarations.mjs +8 -0
  64. package/dist/utils/equal-selectors.cjs +70 -0
  65. package/dist/utils/equal-selectors.d.ts +2 -0
  66. package/dist/utils/equal-selectors.mjs +68 -0
  67. package/dist/utils/equal-variants.cjs +10 -0
  68. package/dist/utils/equal-variants.d.ts +2 -0
  69. package/dist/utils/equal-variants.mjs +8 -0
  70. package/dist/utils/extend-config.cjs +0 -1
  71. package/dist/utils/extend-config.mjs +0 -1
  72. package/dist/utils/generate-at.cjs +30 -0
  73. package/dist/utils/generate-at.d.ts +2 -0
  74. package/dist/utils/generate-at.mjs +28 -0
  75. package/dist/utils/generate-selector.cjs +49 -0
  76. package/dist/utils/generate-selector.d.ts +2 -0
  77. package/dist/utils/generate-selector.mjs +47 -0
  78. package/dist/utils/get-single-at-number-rule-node.cjs +9 -0
  79. package/dist/utils/get-single-at-number-rule-node.d.ts +2 -0
  80. package/dist/utils/get-single-at-number-rule-node.mjs +7 -0
  81. package/dist/utils/parse-at.cjs +157 -0
  82. package/dist/utils/parse-at.d.ts +39 -0
  83. package/dist/utils/parse-at.mjs +155 -0
  84. package/dist/utils/parse-pair.cjs +51 -0
  85. package/dist/utils/parse-pair.d.ts +8 -0
  86. package/dist/utils/parse-pair.mjs +49 -0
  87. package/dist/utils/parse-selector.cjs +112 -0
  88. package/dist/utils/parse-selector.d.ts +19 -0
  89. package/dist/utils/parse-selector.mjs +110 -0
  90. package/dist/utils/parse-value.cjs +39 -0
  91. package/dist/utils/parse-value.d.ts +2 -0
  92. package/dist/utils/parse-value.mjs +37 -0
  93. package/dist/utils/replace-char-outside-quotes.cjs +21 -0
  94. package/dist/utils/replace-char-outside-quotes.d.ts +1 -0
  95. package/dist/utils/replace-char-outside-quotes.mjs +19 -0
  96. package/dist/utils/sort-readable-classes.cjs +74 -0
  97. package/dist/utils/{reorder-for-readable-classes.d.ts → sort-readable-classes.d.ts} +1 -1
  98. package/dist/utils/sort-readable-classes.mjs +72 -0
  99. package/dist/utils/split-char-outside-quotes.cjs +29 -0
  100. package/dist/utils/split-char-outside-quotes.d.ts +1 -0
  101. package/dist/utils/split-char-outside-quotes.mjs +27 -0
  102. package/dist/variable-rule.cjs +86 -0
  103. package/dist/variable-rule.d.ts +23 -0
  104. package/dist/variable-rule.mjs +81 -0
  105. package/package.json +1 -1
  106. package/dist/utils/are-rule-at-equal.cjs +0 -22
  107. package/dist/utils/are-rule-at-equal.d.ts +0 -2
  108. package/dist/utils/are-rule-at-equal.mjs +0 -20
  109. package/dist/utils/are-rule-modes-equal.cjs +0 -7
  110. package/dist/utils/are-rule-modes-equal.d.ts +0 -2
  111. package/dist/utils/are-rule-modes-equal.mjs +0 -5
  112. package/dist/utils/are-rule-selectors-equal.cjs +0 -29
  113. package/dist/utils/are-rule-selectors-equal.d.ts +0 -2
  114. package/dist/utils/are-rule-selectors-equal.mjs +0 -27
  115. package/dist/utils/are-rule-states-equal.cjs +0 -11
  116. package/dist/utils/are-rule-states-equal.d.ts +0 -2
  117. package/dist/utils/are-rule-states-equal.mjs +0 -9
  118. package/dist/utils/are-rules-duplicated.cjs +0 -17
  119. package/dist/utils/are-rules-duplicated.d.ts +0 -2
  120. package/dist/utils/are-rules-duplicated.mjs +0 -15
  121. package/dist/utils/reorder-for-readable-classes.cjs +0 -62
  122. package/dist/utils/reorder-for-readable-classes.mjs +0 -60
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var rule = require('../rule.cjs');
3
+ var animationRule = require('../animation-rule.cjs');
4
+ var compareRulePriority = require('../utils/compare-rule-priority.cjs');
5
+ var variableRule = require('../variable-rule.cjs');
4
6
 
5
7
  function withSyntaxLayer(Base) {
6
8
  return class SyntaxLayer extends Base {
@@ -13,172 +15,13 @@ function withSyntaxLayer(Base) {
13
15
  * media width
14
16
  * media width selectors
15
17
  */ insert(syntaxRule) {
16
- if (this.rules.includes(syntaxRule)) return;
17
- let index;
18
- /**
19
- * 必須按斷點值遞增,並透過索引插入,
20
- * 以實現響應式先後套用的規則
21
- * @example <1 <2 <3 ALL >=1 >=2 >=3
22
- * @description
23
- */ const endIndex = this.rules.length - 1;
24
- const { at, atToken, order, priority } = syntaxRule;
25
- const findIndex = (startIndex, stopCheck, matchCheck)=>{
26
- let i = startIndex;
27
- for(; i <= endIndex; i++){
28
- const eachSyntaxRule = this.rules[i];
29
- if (stopCheck?.(eachSyntaxRule)) return matchCheck ? -1 : i - 1;
30
- if (matchCheck?.(eachSyntaxRule)) return i;
31
- }
32
- return matchCheck ? -1 : i - 1;
33
- };
34
- let matchStartIndex;
35
- let matchEndIndex;
36
- if (atToken) {
37
- const mediaStartIndex = this.rules.findIndex((eachSyntaxRule)=>eachSyntaxRule.at?.media);
38
- if (mediaStartIndex === -1) {
39
- index = endIndex + 1;
40
- } else {
41
- const maxWidthFeature = at.media?.find(({ name })=>name === 'max-width');
42
- const minWidthFeature = at.media?.find(({ name })=>name === 'min-width');
43
- if (maxWidthFeature || minWidthFeature) {
44
- const mediaWidthStartIndex = this.rules.findIndex((eachSyntaxRule)=>eachSyntaxRule.at?.media?.find(({ name })=>name === 'max-width' || name === 'min-width'));
45
- if (mediaWidthStartIndex === -1) {
46
- index = endIndex + 1;
47
- } else {
48
- if (maxWidthFeature && minWidthFeature) {
49
- /**
50
- * 範圍越小 ( 越限定 越侷限 ) 越優先,
51
- * 按照範圍 max-width - min-width 遞減排序
52
- * find 第一個所遇到同樣 feature 且範圍值比自己大的 rule,
53
- * 並插入在該 rule 之後,讓自己優先被套用
54
- */ if (priority === -1) {
55
- matchStartIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.priority !== -1, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width'));
56
- matchEndIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.priority !== -1);
57
- } else {
58
- matchStartIndex = findIndex(mediaWidthStartIndex, undefined, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') && eachSyntaxRule.priority !== -1);
59
- matchEndIndex = endIndex;
60
- }
61
- if (matchStartIndex !== -1) {
62
- const range = maxWidthFeature.value - minWidthFeature.value;
63
- let i = matchEndIndex;
64
- const endI = matchStartIndex;
65
- matchStartIndex = matchEndIndex + 1;
66
- for(; i >= endI; i--){
67
- const eachSyntaxRule = this.rules[i];
68
- const eachMaxWidthFeature = eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width');
69
- const eachMinWidthFeature = eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width');
70
- if (!eachMaxWidthFeature || !eachMinWidthFeature) {
71
- break;
72
- } else {
73
- const eachRange = eachMaxWidthFeature.value - eachMinWidthFeature.value;
74
- if (eachRange < range) {
75
- matchEndIndex = i - 1;
76
- } else if (eachRange === range) {
77
- matchStartIndex = i;
78
- } else {
79
- break;
80
- }
81
- }
82
- }
83
- }
84
- } else if (minWidthFeature) {
85
- /**
86
- * find 第一個所遇到同樣 feature 且值比自己大的 rule,
87
- * 並插入在該 rule 之後,讓自己優先被套用
88
- */ if (priority === -1) {
89
- matchStartIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') || eachSyntaxRule.priority !== -1, (eachSyntaxRule)=>!eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width'));
90
- matchEndIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') || eachSyntaxRule.priority !== -1);
91
- } else {
92
- matchStartIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') && eachSyntaxRule.priority !== -1, (eachSyntaxRule)=>!eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') && eachSyntaxRule.priority !== -1);
93
- matchEndIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') && eachSyntaxRule.priority !== -1);
94
- }
95
- if (matchStartIndex !== -1) {
96
- for(let i = matchEndIndex; i >= matchStartIndex; i--){
97
- const feature = this.rules[i].at.media?.find(({ name })=>name === 'min-width');
98
- if (!feature) continue;
99
- if (feature.value > minWidthFeature.value) {
100
- matchEndIndex = i - 1;
101
- } else if (feature.value < minWidthFeature.value) {
102
- matchStartIndex = i + 1;
103
- break;
104
- }
105
- }
106
- }
107
- } else {
108
- /**
109
- * find 第一個所遇到同樣 feature 且值比自己大的 rule,
110
- * 並插入在該 rule 之後,讓自己優先被套用
111
- */ if (priority === -1) {
112
- matchStartIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') || eachSyntaxRule.priority !== -1, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width'));
113
- matchEndIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') || eachSyntaxRule.priority !== -1);
114
- } else {
115
- matchStartIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') && eachSyntaxRule.priority !== -1, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width') && eachSyntaxRule.priority !== -1);
116
- matchEndIndex = findIndex(mediaWidthStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'min-width') && eachSyntaxRule.priority !== -1);
117
- }
118
- if (matchStartIndex !== -1) {
119
- for(let i = matchEndIndex; i >= matchStartIndex; i--){
120
- const feature = this.rules[i].at.media?.find(({ name })=>name === 'max-width');
121
- if (!feature) continue;
122
- if (feature.value < maxWidthFeature.value) {
123
- matchEndIndex = i - 1;
124
- } else if (feature.value > maxWidthFeature.value) {
125
- matchStartIndex = i + 1;
126
- break;
127
- }
128
- }
129
- }
130
- }
131
- }
132
- } else {
133
- if (priority === -1) {
134
- matchStartIndex = mediaStartIndex;
135
- matchEndIndex = findIndex(mediaStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width' || name === 'min-width') || eachSyntaxRule.priority !== -1);
136
- } else {
137
- matchStartIndex = findIndex(mediaStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width' || name === 'min-width'), (eachSyntaxRule)=>eachSyntaxRule.priority !== -1);
138
- matchEndIndex = findIndex(mediaStartIndex, (eachSyntaxRule)=>eachSyntaxRule.at.media?.find(({ name })=>name === 'max-width' || name === 'min-width'));
139
- }
140
- }
141
- }
142
- } else {
143
- if (priority === -1) {
144
- matchStartIndex = 0;
145
- matchEndIndex = findIndex(0, (eachSyntax)=>eachSyntax.atToken || eachSyntax.priority !== -1);
146
- } else {
147
- matchStartIndex = findIndex(0, (eachSyntax)=>eachSyntax.atToken, (eachSyntax)=>eachSyntax.priority !== -1);
148
- matchEndIndex = findIndex(0, (eachSyntax)=>eachSyntax.atToken);
149
- }
150
- }
151
- if (index === undefined && matchEndIndex !== undefined && matchStartIndex !== undefined) {
152
- if (matchStartIndex === -1) {
153
- index = matchEndIndex + 1;
154
- } else {
155
- if (priority === -1) {
156
- for(let i = matchStartIndex; i <= matchEndIndex; i++){
157
- const currentSyntaxRule = this.rules[i];
158
- if (currentSyntaxRule.order >= order) {
159
- index = i;
160
- break;
161
- }
162
- }
163
- } else {
164
- for(let i = matchStartIndex; i <= matchEndIndex; i++){
165
- const currentSyntaxRule = this.rules[i];
166
- if (currentSyntaxRule.priority < priority) {
167
- index = i;
168
- break;
169
- } else if (currentSyntaxRule.priority === priority) {
170
- if (currentSyntaxRule.order >= order) {
171
- index = i;
172
- break;
173
- }
174
- } else {
175
- index = i + 1;
176
- }
177
- }
178
- }
179
- if (index === undefined) {
180
- index = matchEndIndex + 1;
181
- }
18
+ if (this.rules.includes(syntaxRule) || !syntaxRule.valid) return;
19
+ let index = this.rules.length;
20
+ for(let i = 0; i < this.rules.length; i++){
21
+ const rule = this.rules[i];
22
+ if (compareRulePriority.default(syntaxRule, rule) < 0) {
23
+ index = i;
24
+ break;
182
25
  }
183
26
  }
184
27
  super.insert(syntaxRule, index);
@@ -199,108 +42,42 @@ function withSyntaxLayer(Base) {
199
42
  layer.tokenCounts.set(layerToken, count - 1);
200
43
  }
201
44
  };
202
- if (syntaxRule.variableNames) {
203
- for (const eachVariableName of syntaxRule.variableNames){
204
- deleteLayerToken(eachVariableName, this.css.themeLayer);
205
- }
206
- }
207
- if (syntaxRule.animationNames) {
208
- for (const eachKeyframeName of syntaxRule.animationNames){
209
- deleteLayerToken(eachKeyframeName, this.css.animationsNonLayer);
210
- }
211
- }
45
+ syntaxRule.variableNames?.forEach((eachVariableName)=>{
46
+ deleteLayerToken(eachVariableName, this.css.themeLayer);
47
+ });
48
+ syntaxRule.animationNames?.forEach((eachAnimationName)=>{
49
+ deleteLayerToken(eachAnimationName, this.css.animationsNonLayer);
50
+ });
212
51
  syntaxRule.definition.delete?.call(syntaxRule, syntaxRule.name);
213
52
  return syntaxRule;
214
53
  }
215
54
  insertVariables(syntaxRule) {
216
- if (syntaxRule.variableNames) {
217
- for (const eachVariableName of syntaxRule.variableNames){
55
+ syntaxRule.variableNames?.forEach((eachVariableName)=>{
56
+ if (this.css.themeLayer.rules.find(({ name })=>name === eachVariableName)) {
57
+ const count = this.css.themeLayer.tokenCounts.get(eachVariableName) || 0;
58
+ this.css.themeLayer.tokenCounts.set(eachVariableName, count + 1);
59
+ } else {
218
60
  const variable = this.css.variables.get(eachVariableName);
219
- if (this.css.themeLayer.rules.find(({ name })=>name === eachVariableName)) {
220
- const count = this.css.themeLayer.tokenCounts.get(eachVariableName) || 0;
221
- this.css.themeLayer.tokenCounts.set(eachVariableName, count + 1);
222
- } else {
223
- const newRule = new rule.Rule(eachVariableName);
224
- const addNative = (mode, _variable)=>{
225
- let isDefaultMode = false;
226
- let preifxCssRuleText;
227
- let selectorText;
228
- let endCurlyBracketCount = 1;
229
- if (mode) {
230
- switch(this.css.config.modes?.[mode]){
231
- case 'media':
232
- selectorText = ':root';
233
- preifxCssRuleText = `@media(prefers-color-scheme:${mode}){${selectorText}`;
234
- endCurlyBracketCount++;
235
- break;
236
- case 'host':
237
- preifxCssRuleText = selectorText = `:host(.${mode})`;
238
- if (!variable?.value && this.css.config.defaultMode === mode) {
239
- preifxCssRuleText += ',:host';
240
- isDefaultMode = true;
241
- }
242
- break;
243
- case 'class':
244
- preifxCssRuleText = selectorText = `.${mode}`;
245
- if (!variable?.value && this.css.config.defaultMode === mode) {
246
- preifxCssRuleText += ',:root';
247
- isDefaultMode = true;
248
- }
249
- break;
250
- default:
251
- return;
252
- }
253
- } else {
254
- preifxCssRuleText = selectorText = ':root';
255
- }
256
- const cssRuleText = `${preifxCssRuleText}{--${eachVariableName}:${String(_variable.value)}${'}'.repeat(endCurlyBracketCount)}`;
257
- if (isDefaultMode) {
258
- newRule.nodes.unshift({
259
- selectorText,
260
- text: cssRuleText
261
- });
262
- } else {
263
- newRule.nodes.push({
264
- text: cssRuleText
265
- });
266
- }
267
- };
268
- if (variable?.value !== undefined) {
269
- addNative('', variable);
270
- }
271
- if (variable?.modes) {
272
- for(const mode in variable.modes){
273
- addNative(mode, variable.modes[mode]);
274
- }
275
- }
276
- this.css.themeLayer.insert(newRule);
277
- this.css.themeLayer.tokenCounts.set(eachVariableName, 1);
278
- }
61
+ if (!variable) return;
62
+ const newRule = new variableRule.default(eachVariableName, variable, this.css);
63
+ this.css.themeLayer.insert(newRule);
64
+ this.css.themeLayer.tokenCounts.set(eachVariableName, 1);
279
65
  }
280
- }
66
+ });
281
67
  }
282
68
  insertAnimations(syntaxRule) {
283
- if (syntaxRule.animationNames) {
284
- for (const eachAnimationName of syntaxRule.animationNames){
285
- if (this.css.animationsNonLayer.rules.find(({ name })=>name === eachAnimationName)) {
286
- const count = this.css.animationsNonLayer.tokenCounts.get(eachAnimationName) || 0;
287
- this.css.animationsNonLayer.tokenCounts.set(eachAnimationName, count + 1);
288
- } else {
289
- const keyframes = this.css.animations.get(eachAnimationName);
290
- if (!keyframes) continue;
291
- const keyframeText = Object.entries(keyframes).reduce((acc, [key, variables])=>{
292
- const variableText = Object.entries(variables).map(([name, value])=>`${name}:${value}`).join(';');
293
- return acc + `${key}{${variableText}}`;
294
- }, '');
295
- this.css.animationsNonLayer.insert(new rule.Rule(eachAnimationName, [
296
- {
297
- text: `@keyframes ${eachAnimationName}{${keyframeText}}`
298
- }
299
- ]));
300
- this.css.animationsNonLayer.tokenCounts.set(eachAnimationName, 1);
301
- }
69
+ syntaxRule.animationNames?.forEach((eachAnimationName)=>{
70
+ if (this.css.animationsNonLayer.rules.find(({ name })=>name === eachAnimationName)) {
71
+ const count = this.css.animationsNonLayer.tokenCounts.get(eachAnimationName) || 0;
72
+ this.css.animationsNonLayer.tokenCounts.set(eachAnimationName, count + 1);
73
+ } else {
74
+ const keyframes = this.css.animations.get(eachAnimationName);
75
+ if (!keyframes) return;
76
+ const newRule = new animationRule(eachAnimationName, keyframes, this.css);
77
+ this.css.animationsNonLayer.insert(newRule);
78
+ this.css.animationsNonLayer.tokenCounts.set(eachAnimationName, 1);
302
79
  }
303
- }
80
+ });
304
81
  }
305
82
  };
306
83
  }