@master/css 2.0.0-rc.62 → 2.0.0-rc.63
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 +2 -0
- package/dist/common.d.ts +1 -0
- package/dist/common.mjs +2 -1
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/utils/parse-selector.cjs +3 -1
- package/dist/utils/parse-selector.d.ts +1 -1
- package/dist/utils/parse-selector.mjs +3 -1
- package/dist/utils/sort-readable-classes.cjs +18 -6
- package/dist/utils/sort-readable-classes.mjs +18 -6
- package/package.json +1 -1
package/dist/common.cjs
CHANGED
|
@@ -178,6 +178,7 @@ const AT_COMPARABLE_FEATURES = [
|
|
|
178
178
|
'height',
|
|
179
179
|
'resolution'
|
|
180
180
|
];
|
|
181
|
+
const __UNSORTED__ = '__UNSORTED__';
|
|
181
182
|
|
|
182
183
|
exports.ANIMATION_SIGN = ANIMATION_SIGN;
|
|
183
184
|
exports.AT_COMPARABLE_FEATURES = AT_COMPARABLE_FEATURES;
|
|
@@ -206,3 +207,4 @@ exports.TRANSITION_SIGN = TRANSITION_SIGN;
|
|
|
206
207
|
exports.UNIT_REGEX = UNIT_REGEX;
|
|
207
208
|
exports.VALUE_DELIMITERS = VALUE_DELIMITERS;
|
|
208
209
|
exports.VALUE_UNITS = VALUE_UNITS;
|
|
210
|
+
exports.__UNSORTED__ = __UNSORTED__;
|
package/dist/common.d.ts
CHANGED
package/dist/common.mjs
CHANGED
|
@@ -176,5 +176,6 @@ const AT_COMPARABLE_FEATURES = [
|
|
|
176
176
|
'height',
|
|
177
177
|
'resolution'
|
|
178
178
|
];
|
|
179
|
+
const __UNSORTED__ = '__UNSORTED__';
|
|
179
180
|
|
|
180
|
-
export { ANIMATION_SIGN, AT_COMPARABLE_FEATURES, AT_COMPARISON_OPERATORS, AT_IDENTIFIERS, AT_LOGICAL_OPERATORS, AT_SIGN, BASE_UNIT_REGEX, BORDER_STYLE_VALUES, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, COMPARISION_OPERATORS, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_COMBINATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS };
|
|
181
|
+
export { ANIMATION_SIGN, AT_COMPARABLE_FEATURES, AT_COMPARISON_OPERATORS, AT_IDENTIFIERS, AT_LOGICAL_OPERATORS, AT_SIGN, BASE_UNIT_REGEX, BORDER_STYLE_VALUES, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, COMPARISION_OPERATORS, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_COMBINATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS, __UNSORTED__ };
|
package/dist/index.cjs
CHANGED
|
@@ -70,6 +70,7 @@ exports.TRANSITION_SIGN = common.TRANSITION_SIGN;
|
|
|
70
70
|
exports.UNIT_REGEX = common.UNIT_REGEX;
|
|
71
71
|
exports.VALUE_DELIMITERS = common.VALUE_DELIMITERS;
|
|
72
72
|
exports.VALUE_UNITS = common.VALUE_UNITS;
|
|
73
|
+
exports.__UNSORTED__ = common.__UNSORTED__;
|
|
73
74
|
exports.MasterCSS = core;
|
|
74
75
|
exports.default = core;
|
|
75
76
|
exports.SyntaxRule = syntaxRule.SyntaxRule;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { config } from './config/index.mjs';
|
|
2
|
-
export { ANIMATION_SIGN, AT_COMPARABLE_FEATURES, AT_COMPARISON_OPERATORS, AT_IDENTIFIERS, AT_LOGICAL_OPERATORS, AT_SIGN, BASE_UNIT_REGEX, BORDER_STYLE_VALUES, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, COMPARISION_OPERATORS, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_COMBINATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS } from './common.mjs';
|
|
2
|
+
export { ANIMATION_SIGN, AT_COMPARABLE_FEATURES, AT_COMPARISON_OPERATORS, AT_IDENTIFIERS, AT_LOGICAL_OPERATORS, AT_SIGN, BASE_UNIT_REGEX, BORDER_STYLE_VALUES, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, COMPARISION_OPERATORS, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_COMBINATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS, __UNSORTED__ } from './common.mjs';
|
|
3
3
|
export { default as MasterCSS, default } from './core.mjs';
|
|
4
4
|
export { SyntaxRule } from './syntax-rule.mjs';
|
|
5
5
|
export { Rule } from './rule.mjs';
|
|
@@ -4,7 +4,7 @@ var common = require('../common.cjs');
|
|
|
4
4
|
var core = require('../core.cjs');
|
|
5
5
|
var parsePair = require('./parse-pair.cjs');
|
|
6
6
|
|
|
7
|
-
const SELECTOR_REGEX = new RegExp(`(?:[a-zA-Z0-9-]+)|([${common.SELECTOR_COMBINATORS.join('')}
|
|
7
|
+
const SELECTOR_REGEX = new RegExp(`(?:[a-zA-Z0-9-]+)|([${common.SELECTOR_COMBINATORS.join('')}.:,*])|(a-zA-Z0-9-)`, 'g');
|
|
8
8
|
function parseSelector(token, css = new core(), isRaw = true) {
|
|
9
9
|
const resolve = (eachToken)=>{
|
|
10
10
|
const nodes = [];
|
|
@@ -44,6 +44,8 @@ function parseSelector(token, css = new core(), isRaw = true) {
|
|
|
44
44
|
}
|
|
45
45
|
} else if (raw === ',') {
|
|
46
46
|
type = 'separator';
|
|
47
|
+
} else if (raw === '*') {
|
|
48
|
+
type = 'universal';
|
|
47
49
|
} else if (currentPrefix === ':') {
|
|
48
50
|
type = 'pseudo-class';
|
|
49
51
|
} else if (currentPrefix === '::') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import MasterCSS from '../core';
|
|
2
2
|
export declare type SelectorLiteralNode = {
|
|
3
|
-
type?: 'attribute' | 'pseudo-class' | 'pseudo-element' | 'class';
|
|
3
|
+
type?: 'attribute' | 'pseudo-class' | 'pseudo-element' | 'class' | 'universal';
|
|
4
4
|
raw?: string;
|
|
5
5
|
value?: string;
|
|
6
6
|
children?: SelectorNode[];
|
|
@@ -2,7 +2,7 @@ import { SELECTOR_COMBINATORS } from '../common.mjs';
|
|
|
2
2
|
import MasterCSS from '../core.mjs';
|
|
3
3
|
import parsePair from './parse-pair.mjs';
|
|
4
4
|
|
|
5
|
-
const SELECTOR_REGEX = new RegExp(`(?:[a-zA-Z0-9-]+)|([${SELECTOR_COMBINATORS.join('')}
|
|
5
|
+
const SELECTOR_REGEX = new RegExp(`(?:[a-zA-Z0-9-]+)|([${SELECTOR_COMBINATORS.join('')}.:,*])|(a-zA-Z0-9-)`, 'g');
|
|
6
6
|
function parseSelector(token, css = new MasterCSS(), isRaw = true) {
|
|
7
7
|
const resolve = (eachToken)=>{
|
|
8
8
|
const nodes = [];
|
|
@@ -42,6 +42,8 @@ function parseSelector(token, css = new MasterCSS(), isRaw = true) {
|
|
|
42
42
|
}
|
|
43
43
|
} else if (raw === ',') {
|
|
44
44
|
type = 'separator';
|
|
45
|
+
} else if (raw === '*') {
|
|
46
|
+
type = 'universal';
|
|
45
47
|
} else if (currentPrefix === ':') {
|
|
46
48
|
type = 'pseudo-class';
|
|
47
49
|
} else if (currentPrefix === '::') {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var syntaxRuleType = require('../syntax-rule-type.cjs');
|
|
4
4
|
var core = require('../core.cjs');
|
|
5
5
|
var compareRulePriority = require('./compare-rule-priority.cjs');
|
|
6
|
+
var common = require('../common.cjs');
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Sorts classes in a consistent order
|
|
@@ -10,7 +11,16 @@ var compareRulePriority = require('./compare-rule-priority.cjs');
|
|
|
10
11
|
* @param options
|
|
11
12
|
* @returns consistent classes
|
|
12
13
|
*/ function sortReadableClasses(classes, css = new core()) {
|
|
13
|
-
|
|
14
|
+
const shouldSortClasses = [];
|
|
15
|
+
const unsortedClasses = [];
|
|
16
|
+
for (const className of classes){
|
|
17
|
+
if (className.includes(common.__UNSORTED__)) {
|
|
18
|
+
unsortedClasses.push(className);
|
|
19
|
+
} else {
|
|
20
|
+
shouldSortClasses.push(className);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
css.add(...shouldSortClasses);
|
|
14
24
|
// 先去重 fixedClass for componentsLayer
|
|
15
25
|
const seenFixed = new Set();
|
|
16
26
|
const dedupedComponentRules = css.componentsLayer.rules.filter((rule)=>{
|
|
@@ -61,13 +71,15 @@ var compareRulePriority = require('./compare-rule-priority.cjs');
|
|
|
61
71
|
return compareRulePriority.default(a.rule, b.rule);
|
|
62
72
|
});
|
|
63
73
|
const orderedClasses = sortedRules.map((entry)=>entry.rule.fixedClass || entry.rule.name);
|
|
64
|
-
|
|
65
|
-
numeric: true
|
|
66
|
-
}));
|
|
67
|
-
css.remove(...classes);
|
|
74
|
+
css.remove(...shouldSortClasses);
|
|
68
75
|
return [
|
|
69
76
|
...orderedClasses,
|
|
70
|
-
...
|
|
77
|
+
...[
|
|
78
|
+
...shouldSortClasses.filter((className)=>orderedClasses.indexOf(className) === -1),
|
|
79
|
+
...unsortedClasses
|
|
80
|
+
].sort((a, b)=>a.localeCompare(b, undefined, {
|
|
81
|
+
numeric: true
|
|
82
|
+
}))
|
|
71
83
|
];
|
|
72
84
|
}
|
|
73
85
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import SyntaxRuleType from '../syntax-rule-type.mjs';
|
|
2
2
|
import MasterCSS from '../core.mjs';
|
|
3
3
|
import compareRulePriority from './compare-rule-priority.mjs';
|
|
4
|
+
import { __UNSORTED__ } from '../common.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Sorts classes in a consistent order
|
|
@@ -8,7 +9,16 @@ import compareRulePriority from './compare-rule-priority.mjs';
|
|
|
8
9
|
* @param options
|
|
9
10
|
* @returns consistent classes
|
|
10
11
|
*/ function sortReadableClasses(classes, css = new MasterCSS()) {
|
|
11
|
-
|
|
12
|
+
const shouldSortClasses = [];
|
|
13
|
+
const unsortedClasses = [];
|
|
14
|
+
for (const className of classes){
|
|
15
|
+
if (className.includes(__UNSORTED__)) {
|
|
16
|
+
unsortedClasses.push(className);
|
|
17
|
+
} else {
|
|
18
|
+
shouldSortClasses.push(className);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
css.add(...shouldSortClasses);
|
|
12
22
|
// 先去重 fixedClass for componentsLayer
|
|
13
23
|
const seenFixed = new Set();
|
|
14
24
|
const dedupedComponentRules = css.componentsLayer.rules.filter((rule)=>{
|
|
@@ -59,13 +69,15 @@ import compareRulePriority from './compare-rule-priority.mjs';
|
|
|
59
69
|
return compareRulePriority(a.rule, b.rule);
|
|
60
70
|
});
|
|
61
71
|
const orderedClasses = sortedRules.map((entry)=>entry.rule.fixedClass || entry.rule.name);
|
|
62
|
-
|
|
63
|
-
numeric: true
|
|
64
|
-
}));
|
|
65
|
-
css.remove(...classes);
|
|
72
|
+
css.remove(...shouldSortClasses);
|
|
66
73
|
return [
|
|
67
74
|
...orderedClasses,
|
|
68
|
-
...
|
|
75
|
+
...[
|
|
76
|
+
...shouldSortClasses.filter((className)=>orderedClasses.indexOf(className) === -1),
|
|
77
|
+
...unsortedClasses
|
|
78
|
+
].sort((a, b)=>a.localeCompare(b, undefined, {
|
|
79
|
+
numeric: true
|
|
80
|
+
}))
|
|
69
81
|
];
|
|
70
82
|
}
|
|
71
83
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"vitest","type-check":"tsc --noEmit","lint":"eslint"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/core"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.mjs"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.1.1","@master/normal.css":"^3.1.0","@techor/extend":"^3.2.0","csstype":"^3.1.3"},"devDependencies":{"shared":"^2.0.0-rc.
|
|
1
|
+
{"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"vitest","type-check":"tsc --noEmit","lint":"eslint"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/core"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.mjs"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.1.1","@master/normal.css":"^3.1.0","@techor/extend":"^3.2.0","csstype":"^3.1.3"},"devDependencies":{"shared":"^2.0.0-rc.63"},"version":"2.0.0-rc.63"}
|