@master/css 2.0.0-rc.26 → 2.0.0-rc.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common.cjs +124 -0
- package/dist/common.d.ts +22 -0
- package/dist/common.mjs +106 -0
- package/dist/config/functions.cjs +40 -41
- package/dist/config/functions.mjs +39 -40
- package/dist/config/index.cjs +3 -3
- package/dist/config/index.d.ts +9 -10
- package/dist/config/index.mjs +3 -3
- package/dist/config/queries.cjs +4 -0
- package/dist/config/queries.d.ts +4 -0
- package/dist/config/queries.mjs +4 -0
- package/dist/config/rules.cjs +964 -851
- package/dist/config/rules.d.ts +8 -5
- package/dist/config/rules.mjs +966 -852
- package/dist/config/selectors.cjs +0 -1
- package/dist/config/selectors.d.ts +0 -1
- package/dist/config/selectors.mjs +0 -1
- package/dist/config/{semantics.cjs → utilities.cjs} +2 -5
- package/dist/config/{semantics.d.ts → utilities.d.ts} +2 -5
- package/dist/config/{semantics.mjs → utilities.mjs} +2 -5
- package/dist/core.cjs +192 -132
- package/dist/core.d.ts +18 -14
- package/dist/core.mjs +193 -133
- package/dist/index.cjs +36 -16
- package/dist/index.d.ts +13 -8
- package/dist/index.mjs +14 -11
- package/dist/layer.cjs +25 -20
- package/dist/layer.d.ts +26 -9
- package/dist/layer.mjs +22 -19
- package/dist/rule.cjs +43 -49
- package/dist/rule.d.ts +37 -24
- package/dist/rule.mjs +43 -49
- package/dist/utils/generate-css.cjs +13 -0
- package/dist/utils/generate-css.d.ts +2 -0
- package/dist/utils/generate-css.mjs +11 -0
- package/dist/utils/hex-to-rgb.cjs +1 -1
- package/dist/utils/hex-to-rgb.d.ts +1 -1
- package/dist/utils/hex-to-rgb.mjs +1 -1
- package/dist/utils/is-core-rule.cjs +9 -0
- package/dist/utils/is-core-rule.d.ts +1 -0
- package/dist/utils/is-core-rule.mjs +7 -0
- package/dist/{functions → utils}/reorder-for-readable-classes.cjs +5 -11
- package/dist/{functions → utils}/reorder-for-readable-classes.d.ts +1 -5
- package/dist/{functions → utils}/reorder-for-readable-classes.mjs +6 -12
- package/package.json +1 -1
- package/dist/constants/base-unit-regex.cjs +0 -5
- package/dist/constants/base-unit-regex.d.ts +0 -1
- package/dist/constants/base-unit-regex.mjs +0 -3
- package/dist/constants/start-symbol.cjs +0 -10
- package/dist/constants/start-symbol.d.ts +0 -6
- package/dist/constants/start-symbol.mjs +0 -8
- package/dist/utils/concat-arrays.cjs +0 -12
- package/dist/utils/concat-arrays.d.ts +0 -1
- package/dist/utils/concat-arrays.mjs +0 -10
- package/dist/utils/get-type.cjs +0 -12
- package/dist/utils/get-type.d.ts +0 -7
- package/dist/utils/get-type.mjs +0 -10
- package/dist/utils/is-plain-object.cjs +0 -15
- package/dist/utils/is-plain-object.d.ts +0 -8
- package/dist/utils/is-plain-object.mjs +0 -13
- package/dist/utils/is-symbol.cjs +0 -14
- package/dist/utils/is-symbol.d.ts +0 -7
- package/dist/utils/is-symbol.mjs +0 -12
- package/dist/utils/rgb-to-hex.cjs +0 -7
- package/dist/utils/rgb-to-hex.d.ts +0 -1
- package/dist/utils/rgb-to-hex.mjs +0 -5
- /package/dist/{functions → utils}/are-rule-modes-equal.cjs +0 -0
- /package/dist/{functions → utils}/are-rule-modes-equal.d.ts +0 -0
- /package/dist/{functions → utils}/are-rule-modes-equal.mjs +0 -0
- /package/dist/{functions → utils}/are-rule-queries-equal.cjs +0 -0
- /package/dist/{functions → utils}/are-rule-queries-equal.d.ts +0 -0
- /package/dist/{functions → utils}/are-rule-queries-equal.mjs +0 -0
- /package/dist/{functions → utils}/are-rule-selectors-equal.cjs +0 -0
- /package/dist/{functions → utils}/are-rule-selectors-equal.d.ts +0 -0
- /package/dist/{functions → utils}/are-rule-selectors-equal.mjs +0 -0
- /package/dist/{functions → utils}/are-rule-states-equal.cjs +0 -0
- /package/dist/{functions → utils}/are-rule-states-equal.d.ts +0 -0
- /package/dist/{functions → utils}/are-rule-states-equal.mjs +0 -0
- /package/dist/{functions → utils}/are-rules-duplicated.cjs +0 -0
- /package/dist/{functions → utils}/are-rules-duplicated.d.ts +0 -0
- /package/dist/{functions → utils}/are-rules-duplicated.mjs +0 -0
- /package/dist/{functions → utils}/extend-config.cjs +0 -0
- /package/dist/{functions → utils}/extend-config.d.ts +0 -0
- /package/dist/{functions → utils}/extend-config.mjs +0 -0
package/dist/index.cjs
CHANGED
|
@@ -4,33 +4,51 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var index = require('./config/index.cjs');
|
|
6
6
|
var rule = require('./rule.cjs');
|
|
7
|
-
var
|
|
7
|
+
var common = require('./common.cjs');
|
|
8
8
|
var core = require('./core.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
9
|
+
var layer = require('./layer.cjs');
|
|
10
|
+
var extendConfig = require('./utils/extend-config.cjs');
|
|
11
|
+
var reorderForReadableClasses = require('./utils/reorder-for-readable-classes.cjs');
|
|
12
|
+
var areRuleModesEqual = require('./utils/are-rule-modes-equal.cjs');
|
|
13
|
+
var areRuleQueriesEqual = require('./utils/are-rule-queries-equal.cjs');
|
|
14
|
+
var areRuleSelectorsEqual = require('./utils/are-rule-selectors-equal.cjs');
|
|
15
|
+
var areRuleStatesEqual = require('./utils/are-rule-states-equal.cjs');
|
|
16
|
+
var areRulesDuplicated = require('./utils/are-rules-duplicated.cjs');
|
|
17
|
+
var generateCss = require('./utils/generate-css.cjs');
|
|
18
|
+
var isCoreRule = require('./utils/is-core-rule.cjs');
|
|
16
19
|
var queries = require('./config/queries.cjs');
|
|
17
20
|
var selectors = require('./config/selectors.cjs');
|
|
18
|
-
var
|
|
19
|
-
var rules = require('./config/rules.cjs');
|
|
21
|
+
var utilities = require('./config/utilities.cjs');
|
|
20
22
|
var functions = require('./config/functions.cjs');
|
|
21
23
|
var animations = require('./config/animations.cjs');
|
|
22
24
|
var variables = require('./config/variables.cjs');
|
|
25
|
+
var rules = require('./config/rules.cjs');
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
|
|
26
29
|
exports.config = index.config;
|
|
27
30
|
exports.Rule = rule.Rule;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
exports.ANIMATION_SIGN = common.ANIMATION_SIGN;
|
|
32
|
+
exports.AT_SIGN = common.AT_SIGN;
|
|
33
|
+
exports.BASE_UNIT_REGEX = common.BASE_UNIT_REGEX;
|
|
34
|
+
exports.COLOR_VALUE_REGEX = common.COLOR_VALUE_REGEX;
|
|
35
|
+
exports.DELIMITER_SIGN = common.DELIMITER_SIGN;
|
|
36
|
+
exports.IMAGE_VALUE_REGEX = common.IMAGE_VALUE_REGEX;
|
|
37
|
+
exports.NUMBER_VALUE_REGEX = common.NUMBER_VALUE_REGEX;
|
|
38
|
+
exports.OFFICIAL_URL = common.OFFICIAL_URL;
|
|
39
|
+
exports.QUERY_COMPARISON_OPERATORS = common.QUERY_COMPARISON_OPERATORS;
|
|
40
|
+
exports.QUERY_LOGICAL_OPERATORS = common.QUERY_LOGICAL_OPERATORS;
|
|
41
|
+
exports.SELECTOR_SIGNS = common.SELECTOR_SIGNS;
|
|
42
|
+
exports.SEPARATOR_SIGN = common.SEPARATOR_SIGN;
|
|
43
|
+
exports.SEPARATOR_SIGNS = common.SEPARATOR_SIGNS;
|
|
44
|
+
exports.TRANSITION_SIGN = common.TRANSITION_SIGN;
|
|
45
|
+
exports.UNIT_REGEX = common.UNIT_REGEX;
|
|
46
|
+
exports.VALUE_DELIMITERS = common.VALUE_DELIMITERS;
|
|
47
|
+
exports.VALUE_UNITS = common.VALUE_UNITS;
|
|
32
48
|
exports.MasterCSS = core.default;
|
|
33
49
|
exports.default = core.default;
|
|
50
|
+
exports.masterCSSs = core.masterCSSs;
|
|
51
|
+
exports.Layer = layer;
|
|
34
52
|
exports.extendConfig = extendConfig;
|
|
35
53
|
exports.reorderForReadableClasses = reorderForReadableClasses;
|
|
36
54
|
exports.areRuleModesEqual = areRuleModesEqual;
|
|
@@ -38,10 +56,12 @@ exports.areRuleQueriesEqual = areRuleQueriesEqual;
|
|
|
38
56
|
exports.areRuleSelectorsEqual = areRuleSelectorsEqual;
|
|
39
57
|
exports.areRuleStatesEqual = areRuleStatesEqual;
|
|
40
58
|
exports.areRulesDuplicated = areRulesDuplicated;
|
|
59
|
+
exports.generateCSS = generateCss;
|
|
60
|
+
exports.isCoreRule = isCoreRule;
|
|
41
61
|
exports.queries = queries;
|
|
42
62
|
exports.selectors = selectors;
|
|
43
|
-
exports.
|
|
44
|
-
exports.rules = rules.default;
|
|
63
|
+
exports.utilities = utilities;
|
|
45
64
|
exports.functions = functions;
|
|
46
65
|
exports.animations = animations;
|
|
47
66
|
exports.variables = variables;
|
|
67
|
+
exports.rules = rules.default;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
export * from './config';
|
|
2
|
+
export * from './rule';
|
|
3
|
+
export * from './common';
|
|
4
|
+
export * from './core';
|
|
2
5
|
export { Rule } from './rule';
|
|
3
|
-
export { Layer } from './layer';
|
|
6
|
+
export { default as Layer } from './layer';
|
|
4
7
|
export { default as MasterCSS, default } from './core';
|
|
5
|
-
export { default as extendConfig } from './
|
|
6
|
-
export { default as reorderForReadableClasses } from './
|
|
7
|
-
export { default as areRuleModesEqual } from './
|
|
8
|
-
export { default as areRuleQueriesEqual } from './
|
|
9
|
-
export { default as areRuleSelectorsEqual } from './
|
|
10
|
-
export { default as areRuleStatesEqual } from './
|
|
11
|
-
export { default as areRulesDuplicated } from './
|
|
8
|
+
export { default as extendConfig } from './utils/extend-config';
|
|
9
|
+
export { default as reorderForReadableClasses } from './utils/reorder-for-readable-classes';
|
|
10
|
+
export { default as areRuleModesEqual } from './utils/are-rule-modes-equal';
|
|
11
|
+
export { default as areRuleQueriesEqual } from './utils/are-rule-queries-equal';
|
|
12
|
+
export { default as areRuleSelectorsEqual } from './utils/are-rule-selectors-equal';
|
|
13
|
+
export { default as areRuleStatesEqual } from './utils/are-rule-states-equal';
|
|
14
|
+
export { default as areRulesDuplicated } from './utils/are-rules-duplicated';
|
|
15
|
+
export { default as generateCSS } from './utils/generate-css';
|
|
16
|
+
export { default as isCoreRule } from './utils/is-core-rule';
|
|
12
17
|
export type { NativeRule, MediaFeatureComponent, MediaQuery } from './rule';
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
export { config } from './config/index.mjs';
|
|
2
2
|
export { Rule } from './rule.mjs';
|
|
3
|
-
export {
|
|
4
|
-
export { default as MasterCSS, default } from './core.mjs';
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as
|
|
8
|
-
export { default as
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
3
|
+
export { ANIMATION_SIGN, AT_SIGN, BASE_UNIT_REGEX, COLOR_VALUE_REGEX, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS } from './common.mjs';
|
|
4
|
+
export { default as MasterCSS, default, masterCSSs } from './core.mjs';
|
|
5
|
+
export { default as Layer } from './layer.mjs';
|
|
6
|
+
export { default as extendConfig } from './utils/extend-config.mjs';
|
|
7
|
+
export { default as reorderForReadableClasses } from './utils/reorder-for-readable-classes.mjs';
|
|
8
|
+
export { default as areRuleModesEqual } from './utils/are-rule-modes-equal.mjs';
|
|
9
|
+
export { default as areRuleQueriesEqual } from './utils/are-rule-queries-equal.mjs';
|
|
10
|
+
export { default as areRuleSelectorsEqual } from './utils/are-rule-selectors-equal.mjs';
|
|
11
|
+
export { default as areRuleStatesEqual } from './utils/are-rule-states-equal.mjs';
|
|
12
|
+
export { default as areRulesDuplicated } from './utils/are-rules-duplicated.mjs';
|
|
13
|
+
export { default as generateCSS } from './utils/generate-css.mjs';
|
|
14
|
+
export { default as isCoreRule } from './utils/is-core-rule.mjs';
|
|
12
15
|
export { default as queries } from './config/queries.mjs';
|
|
13
16
|
export { default as selectors } from './config/selectors.mjs';
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as rules } from './config/rules.mjs';
|
|
17
|
+
export { default as utilities } from './config/utilities.mjs';
|
|
16
18
|
export { default as functions } from './config/functions.mjs';
|
|
17
19
|
export { default as animations } from './config/animations.mjs';
|
|
18
20
|
export { default as variables } from './config/variables.mjs';
|
|
21
|
+
export { default as rules } from './config/rules.mjs';
|
package/dist/layer.cjs
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var Layer;
|
|
4
4
|
(function(Layer) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
/**
|
|
6
|
+
* utility classes
|
|
7
|
+
* @example block, inline
|
|
8
|
+
*/ Layer[Layer["Utility"] = -4] = "Utility";
|
|
9
|
+
/**
|
|
10
|
+
* native shorthand
|
|
11
|
+
* @example border, padding, margin
|
|
12
|
+
*/ Layer[Layer["NativeShorthand"] = -3] = "NativeShorthand";
|
|
13
|
+
/**
|
|
14
|
+
* shorthand
|
|
15
|
+
* @example px, py, mx, my
|
|
16
|
+
*/ Layer[Layer["Shorthand"] = -2] = "Shorthand";
|
|
17
|
+
/**
|
|
18
|
+
* native properties
|
|
19
|
+
* @example color, background-color, font-size
|
|
20
|
+
*/ Layer[Layer["Native"] = -1] = "Native";
|
|
21
|
+
/**
|
|
22
|
+
* normal
|
|
23
|
+
* @example grid-cols
|
|
24
|
+
*/ Layer[Layer["Normal"] = 0] = "Normal";
|
|
25
|
+
})(Layer || (Layer = {}));
|
|
26
|
+
var Layer$1 = Layer;
|
|
27
|
+
|
|
28
|
+
module.exports = Layer$1;
|
package/dist/layer.d.ts
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
declare const enum Layer {
|
|
2
|
+
/**
|
|
3
|
+
* utility classes
|
|
4
|
+
* @example block, inline
|
|
5
|
+
*/
|
|
6
|
+
Utility = -4,
|
|
7
|
+
/**
|
|
8
|
+
* native shorthand
|
|
9
|
+
* @example border, padding, margin
|
|
10
|
+
*/
|
|
11
|
+
NativeShorthand = -3,
|
|
12
|
+
/**
|
|
13
|
+
* shorthand
|
|
14
|
+
* @example px, py, mx, my
|
|
15
|
+
*/
|
|
16
|
+
Shorthand = -2,
|
|
17
|
+
/**
|
|
18
|
+
* native properties
|
|
19
|
+
* @example color, background-color, font-size
|
|
20
|
+
*/
|
|
21
|
+
Native = -1,
|
|
22
|
+
/**
|
|
23
|
+
* normal
|
|
24
|
+
* @example grid-cols
|
|
25
|
+
*/
|
|
10
26
|
Normal = 0
|
|
11
27
|
}
|
|
28
|
+
export default Layer;
|
package/dist/layer.mjs
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
var Layer;
|
|
2
2
|
(function(Layer) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
/**
|
|
4
|
+
* utility classes
|
|
5
|
+
* @example block, inline
|
|
6
|
+
*/ Layer[Layer["Utility"] = -4] = "Utility";
|
|
7
|
+
/**
|
|
8
|
+
* native shorthand
|
|
9
|
+
* @example border, padding, margin
|
|
10
|
+
*/ Layer[Layer["NativeShorthand"] = -3] = "NativeShorthand";
|
|
11
|
+
/**
|
|
12
|
+
* shorthand
|
|
13
|
+
* @example px, py, mx, my
|
|
14
|
+
*/ Layer[Layer["Shorthand"] = -2] = "Shorthand";
|
|
15
|
+
/**
|
|
16
|
+
* native properties
|
|
17
|
+
* @example color, background-color, font-size
|
|
18
|
+
*/ Layer[Layer["Native"] = -1] = "Native";
|
|
19
|
+
/**
|
|
20
|
+
* normal
|
|
21
|
+
* @example grid-cols
|
|
22
|
+
*/ Layer[Layer["Normal"] = 0] = "Normal";
|
|
21
23
|
})(Layer || (Layer = {}));
|
|
24
|
+
var Layer$1 = Layer;
|
|
22
25
|
|
|
23
|
-
export { Layer };
|
|
26
|
+
export { Layer$1 as default };
|
package/dist/rule.cjs
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var startSymbol = require('./constants/start-symbol.cjs');
|
|
4
3
|
var cssEscape = require('./shared/utils/css-escape.cjs');
|
|
5
4
|
var layer = require('./layer.cjs');
|
|
6
|
-
var
|
|
5
|
+
var common = require('./common.cjs');
|
|
7
6
|
|
|
8
7
|
class Rule {
|
|
9
8
|
className;
|
|
9
|
+
RegisteredRule;
|
|
10
10
|
css;
|
|
11
11
|
at;
|
|
12
12
|
priority;
|
|
13
13
|
natives;
|
|
14
14
|
order;
|
|
15
15
|
layer;
|
|
16
|
-
atToken;
|
|
17
|
-
stateToken;
|
|
18
16
|
declarations;
|
|
19
17
|
animationNames;
|
|
20
18
|
variableNames;
|
|
21
19
|
constructor(className, RegisteredRule, css){
|
|
22
20
|
this.className = className;
|
|
21
|
+
this.RegisteredRule = RegisteredRule;
|
|
23
22
|
this.css = css;
|
|
24
23
|
this.at = {};
|
|
25
24
|
this.priority = -1;
|
|
26
25
|
this.natives = [];
|
|
27
26
|
this.order = 0;
|
|
28
27
|
this.layer = 0;
|
|
29
|
-
this.atToken = '';
|
|
30
28
|
this.resolveValue = (valueComponents, unit, bypassVariableNames, bypassParsing)=>{
|
|
31
29
|
const { functions } = this.css.config;
|
|
32
30
|
let currentValue = '';
|
|
@@ -37,12 +35,12 @@ class Rule {
|
|
|
37
35
|
const functionDefinition = functions && functions[eachValueComponent.name];
|
|
38
36
|
if (functionDefinition?.transform && !eachValueComponent.bypassTransform) {
|
|
39
37
|
const result = functionDefinition.transform.call(this, this.resolveValue(eachValueComponent.children, functionDefinition.unit ?? unit, bypassVariableNames, bypassParsing || eachValueComponent.name === 'calc'), bypassVariableNames);
|
|
40
|
-
currentValue += eachValueComponent.text = typeof result === 'string' ? result : this.resolveValue(result, functionDefinition?.unit ?? unit, bypassVariableNames, bypassParsing);
|
|
38
|
+
currentValue += eachValueComponent.token = eachValueComponent.text = typeof result === 'string' ? result : this.resolveValue(result, functionDefinition?.unit ?? unit, bypassVariableNames, bypassParsing);
|
|
41
39
|
} else {
|
|
42
|
-
currentValue += eachValueComponent.text = eachValueComponent.name + eachValueComponent.symbol + this.resolveValue(eachValueComponent.children, functionDefinition?.unit ?? unit, bypassVariableNames, bypassParsing) +
|
|
40
|
+
currentValue += eachValueComponent.token = eachValueComponent.text = eachValueComponent.name + eachValueComponent.symbol + this.resolveValue(eachValueComponent.children, functionDefinition?.unit ?? unit, bypassVariableNames, bypassParsing) + common.VALUE_DELIMITERS[eachValueComponent.symbol];
|
|
43
41
|
}
|
|
44
42
|
break;
|
|
45
|
-
// todo: 應挪到
|
|
43
|
+
// todo: 應挪到 parseValues 階段處理才能支援 variables: { x: 'calc(20vw-30px)' } 這種情況,並且解析上可能會比較合理、精簡
|
|
46
44
|
case 'variable':
|
|
47
45
|
// eslint-disable-next-line no-case-declarations
|
|
48
46
|
const variable = this.css.variables[eachValueComponent.name];
|
|
@@ -71,7 +69,7 @@ class Rule {
|
|
|
71
69
|
case 'string':
|
|
72
70
|
handleVariable((variable)=>{
|
|
73
71
|
const valueComponents = [];
|
|
74
|
-
this.
|
|
72
|
+
this.parseValues(valueComponents, 0, variable.value, unit, '', undefined, bypassParsing, [
|
|
75
73
|
...bypassVariableNames,
|
|
76
74
|
eachValueComponent.name
|
|
77
75
|
]);
|
|
@@ -86,9 +84,9 @@ class Rule {
|
|
|
86
84
|
case 'number':
|
|
87
85
|
handleVariable((variable)=>{
|
|
88
86
|
if (bypassParsing) {
|
|
89
|
-
currentValue += eachValueComponent.text = variable.value;
|
|
87
|
+
currentValue += eachValueComponent.text = String(variable.value);
|
|
90
88
|
} else {
|
|
91
|
-
const valueComponent = this.
|
|
89
|
+
const valueComponent = this.parseValue(variable.value, unit);
|
|
92
90
|
currentValue += eachValueComponent.text = valueComponent.value + (valueComponent.unit ?? '');
|
|
93
91
|
}
|
|
94
92
|
}, ()=>{
|
|
@@ -122,7 +120,7 @@ class Rule {
|
|
|
122
120
|
}
|
|
123
121
|
return currentValue;
|
|
124
122
|
};
|
|
125
|
-
this.
|
|
123
|
+
this.parseValues = (currentValueComponents, i, value, unit, endSymbol, parentFunctionName, bypassParsing = false, bypassVariableNames = [])=>{
|
|
126
124
|
const root = parentFunctionName === undefined;
|
|
127
125
|
const isVarFunction = !root && (parentFunctionName.endsWith('$') || parentFunctionName.endsWith('var'));
|
|
128
126
|
const checkIsString = (value)=>value === '\'' || value === '"';
|
|
@@ -147,7 +145,8 @@ class Rule {
|
|
|
147
145
|
const valueComponent = {
|
|
148
146
|
type: 'variable',
|
|
149
147
|
name,
|
|
150
|
-
variable: this.css.variables[name]
|
|
148
|
+
variable: this.css.variables[name],
|
|
149
|
+
token: currentValue
|
|
151
150
|
};
|
|
152
151
|
if (alpha) valueComponent.alpha = alpha;
|
|
153
152
|
currentValueComponents.push(valueComponent);
|
|
@@ -155,14 +154,14 @@ class Rule {
|
|
|
155
154
|
}
|
|
156
155
|
};
|
|
157
156
|
handleVariable(currentValue);
|
|
158
|
-
if (!handled
|
|
157
|
+
if (!handled) {
|
|
159
158
|
const [colorName, alpha] = currentValue.split('/');
|
|
160
159
|
handleVariable(colorName, alpha);
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
if (!handled) {
|
|
164
163
|
if (!isVarFunction) {
|
|
165
|
-
const result =
|
|
164
|
+
const result = common.BASE_UNIT_REGEX.exec(currentValue);
|
|
166
165
|
if (result) {
|
|
167
166
|
currentValue = String(+result[1] * (this.css.config.baseUnit ?? 1));
|
|
168
167
|
}
|
|
@@ -170,10 +169,14 @@ class Rule {
|
|
|
170
169
|
if (bypassParsing) {
|
|
171
170
|
currentValueComponents.push({
|
|
172
171
|
type: 'string',
|
|
173
|
-
value: currentValue
|
|
172
|
+
value: currentValue,
|
|
173
|
+
token: currentValue
|
|
174
174
|
});
|
|
175
175
|
} else {
|
|
176
|
-
currentValueComponents.push(
|
|
176
|
+
currentValueComponents.push({
|
|
177
|
+
...this.parseValue(currentValue, unit),
|
|
178
|
+
token: currentValue
|
|
179
|
+
});
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
currentValue = '';
|
|
@@ -198,27 +201,25 @@ class Rule {
|
|
|
198
201
|
parse();
|
|
199
202
|
}
|
|
200
203
|
return i;
|
|
201
|
-
} else if (!isString && val in
|
|
204
|
+
} else if (!isString && val in common.VALUE_DELIMITERS) {
|
|
202
205
|
const functionName = currentValue;
|
|
203
206
|
const newValueComponent = {
|
|
204
207
|
type: 'function',
|
|
205
208
|
name: functionName,
|
|
206
209
|
symbol: val,
|
|
207
|
-
children: []
|
|
210
|
+
children: [],
|
|
211
|
+
token: ''
|
|
208
212
|
};
|
|
209
213
|
currentValueComponents.push(newValueComponent);
|
|
210
214
|
currentValue = '';
|
|
211
215
|
const functionDefinition = val === '(' ? this.css.config.functions?.[functionName] : undefined;
|
|
212
|
-
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
this.colored = true;
|
|
215
|
-
}
|
|
216
|
-
i = this.parseValue(newValueComponent.children, ++i, value, functionDefinition?.unit ?? unit, startSymbol.START_SYMBOLS[val], functionName || parentFunctionName || '', bypassParsing || functionName === 'calc');
|
|
216
|
+
i = this.parseValues(newValueComponent.children, ++i, value, functionDefinition?.unit ?? unit, common.VALUE_DELIMITERS[val], functionName || parentFunctionName || '', bypassParsing || functionName === 'calc');
|
|
217
217
|
} else if ((val === '|' || val === ' ') && endSymbol !== '}' && (!isString || parentFunctionName === 'path')) {
|
|
218
218
|
parse();
|
|
219
219
|
currentValueComponents.push({
|
|
220
220
|
type: 'separator',
|
|
221
|
-
value: ' '
|
|
221
|
+
value: ' ',
|
|
222
|
+
token: val
|
|
222
223
|
});
|
|
223
224
|
} else {
|
|
224
225
|
if (!isString) {
|
|
@@ -233,7 +234,8 @@ class Rule {
|
|
|
233
234
|
currentValueComponents.push({
|
|
234
235
|
type: 'separator',
|
|
235
236
|
value: val,
|
|
236
|
-
text: (val === ',' ? '' : ' ') + val + (val === ',' ? '' : ' ')
|
|
237
|
+
text: (val === ',' ? '' : ' ') + val + (val === ',' ? '' : ' '),
|
|
238
|
+
token: val
|
|
237
239
|
});
|
|
238
240
|
continue;
|
|
239
241
|
} else if (root && (val === '#' && (currentValue || currentValueComponents.length && currentValueComponents[currentValueComponents.length - 1]['type'] !== 'separator') || [
|
|
@@ -258,9 +260,8 @@ class Rule {
|
|
|
258
260
|
};
|
|
259
261
|
Object.assign(this, RegisteredRule);
|
|
260
262
|
const { id, definition } = RegisteredRule;
|
|
261
|
-
const { analyze, transformValue, declare, transformValueComponents, create, layer: layer$1, unit
|
|
263
|
+
const { analyze, transformValue, declare, transformValueComponents, create, layer: layer$1, unit } = definition;
|
|
262
264
|
this.layer = layer$1;
|
|
263
|
-
this.colored = !!colored;
|
|
264
265
|
if (!definition.unit) definition.unit = '';
|
|
265
266
|
if (!definition.separators) definition.separators = [
|
|
266
267
|
','
|
|
@@ -273,7 +274,7 @@ class Rule {
|
|
|
273
274
|
this.declarations = definition.declarations;
|
|
274
275
|
let stateToken;
|
|
275
276
|
let prefixToken;
|
|
276
|
-
if (layer$1 === layer.
|
|
277
|
+
if (layer$1 === layer.Utility) {
|
|
277
278
|
// TODO: id 使用其他方式傳遞
|
|
278
279
|
stateToken = className.slice(id.length - 1);
|
|
279
280
|
} else {
|
|
@@ -282,11 +283,13 @@ class Rule {
|
|
|
282
283
|
[valueToken, prefixToken] = analyze.call(this, className);
|
|
283
284
|
} else {
|
|
284
285
|
const indexOfColon = className.indexOf(':');
|
|
285
|
-
this.
|
|
286
|
+
this.keyToken = className.slice(0, indexOfColon + 1);
|
|
286
287
|
valueToken = className.slice(indexOfColon + 1);
|
|
287
288
|
}
|
|
288
289
|
this.valueComponents = [];
|
|
289
|
-
|
|
290
|
+
const parsedValueIndex = this.parseValues(this.valueComponents, 0, valueToken, unit, '', undefined, false, definition.includeAnimations ? Object.keys(this.css.animations) : []);
|
|
291
|
+
this.valueToken = valueToken.slice(0, parsedValueIndex);
|
|
292
|
+
stateToken = valueToken.slice(parsedValueIndex);
|
|
290
293
|
}
|
|
291
294
|
// 2. !important
|
|
292
295
|
if (stateToken[0] === '!') {
|
|
@@ -451,8 +454,8 @@ class Rule {
|
|
|
451
454
|
// 5. atTokens
|
|
452
455
|
for(let i = 1; i < stateTokens.length; i++){
|
|
453
456
|
const atToken = stateTokens[i];
|
|
457
|
+
this.atToken = (this.atToken || '') + '@' + atToken;
|
|
454
458
|
if (atToken) {
|
|
455
|
-
this.atToken += '@' + atToken;
|
|
456
459
|
if (atToken === 'rtl' || atToken === 'ltr') {
|
|
457
460
|
this.direction = atToken;
|
|
458
461
|
} else {
|
|
@@ -470,14 +473,7 @@ class Rule {
|
|
|
470
473
|
});
|
|
471
474
|
} else {
|
|
472
475
|
const analyzeToken = (atComponentToken)=>{
|
|
473
|
-
if (atComponentToken === '
|
|
474
|
-
queryType = 'media';
|
|
475
|
-
atComponents.push({
|
|
476
|
-
type: 'media-type',
|
|
477
|
-
token: atComponentToken,
|
|
478
|
-
value: atComponentToken
|
|
479
|
-
});
|
|
480
|
-
} else if (atComponentToken === '&') {
|
|
476
|
+
if (atComponentToken === '&') {
|
|
481
477
|
atComponents.push({
|
|
482
478
|
type: 'operator',
|
|
483
479
|
token: atComponentToken,
|
|
@@ -529,7 +525,7 @@ class Rule {
|
|
|
529
525
|
unit: 'px'
|
|
530
526
|
});
|
|
531
527
|
} else {
|
|
532
|
-
const valueComponent = this.
|
|
528
|
+
const valueComponent = this.parseValue(token, 'px');
|
|
533
529
|
if (valueComponent.type === 'number') {
|
|
534
530
|
atComponents.push({
|
|
535
531
|
type: 'feature',
|
|
@@ -607,14 +603,14 @@ class Rule {
|
|
|
607
603
|
}
|
|
608
604
|
propertiesText.push(propertyText + ((this.important || important) && !propertyText.endsWith('!important') ? '!important' : ''));
|
|
609
605
|
};
|
|
610
|
-
const
|
|
606
|
+
const keyToken = propertyName + ':';
|
|
611
607
|
const declarations = this.declarations[propertyName];
|
|
612
608
|
if (Array.isArray(declarations)) {
|
|
613
609
|
for (const value of declarations){
|
|
614
|
-
push(
|
|
610
|
+
push(keyToken + String(value));
|
|
615
611
|
}
|
|
616
612
|
} else {
|
|
617
|
-
push(
|
|
613
|
+
push(keyToken + String(declarations));
|
|
618
614
|
}
|
|
619
615
|
}
|
|
620
616
|
// 創建 Natives
|
|
@@ -653,8 +649,6 @@ class Rule {
|
|
|
653
649
|
switch(atComponent.type){
|
|
654
650
|
case 'arbitrary':
|
|
655
651
|
return atComponent.value;
|
|
656
|
-
case 'media-type':
|
|
657
|
-
return atComponent.value;
|
|
658
652
|
case 'feature':
|
|
659
653
|
return '(' + atComponent.name + ':' + atComponent.value + (atComponent.unit || '') + ')';
|
|
660
654
|
case 'operator':
|
|
@@ -665,8 +659,8 @@ class Rule {
|
|
|
665
659
|
get text() {
|
|
666
660
|
return this.natives.map((eachNative)=>eachNative.text).join('');
|
|
667
661
|
}
|
|
668
|
-
|
|
669
|
-
|
|
662
|
+
parseValues;
|
|
663
|
+
parseValue(token, unit = this.definition.unit) {
|
|
670
664
|
const defaultUnit = unit ?? this.definition.unit;
|
|
671
665
|
let newUnit = '';
|
|
672
666
|
let value;
|
|
@@ -697,7 +691,7 @@ class Rule {
|
|
|
697
691
|
type: 'number'
|
|
698
692
|
};
|
|
699
693
|
}
|
|
700
|
-
const matches = token.match(
|
|
694
|
+
const matches = token.match(common.UNIT_REGEX);
|
|
701
695
|
// ['0.5deg', '0.5', 'deg', index: 0, input: '0.5deg', groups: undefined]
|
|
702
696
|
if (matches) {
|
|
703
697
|
value = +matches[1];
|