@master/css 2.0.0-rc.47 → 2.0.0-rc.49
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 +1 -1
- package/dist/common.mjs +1 -1
- package/dist/config/functions.d.ts +1 -1
- package/dist/config/index.cjs +3 -3
- package/dist/config/index.d.ts +3 -48
- package/dist/config/index.mjs +3 -3
- package/dist/config/modes.d.ts +1 -1
- package/dist/config/{syntaxes.cjs → rules.cjs} +282 -282
- package/dist/config/rules.d.ts +282 -0
- package/dist/config/{syntaxes.mjs → rules.mjs} +282 -282
- package/dist/core.cjs +229 -611
- package/dist/core.d.ts +36 -67
- package/dist/core.mjs +229 -611
- package/dist/index.cjs +14 -6
- package/dist/index.d.ts +8 -4
- package/dist/index.mjs +7 -3
- package/dist/layer.cjs +107 -23
- package/dist/layer.d.ts +13 -27
- package/dist/layer.mjs +107 -23
- package/dist/non-layer.cjs +65 -0
- package/dist/non-layer.d.ts +12 -0
- package/dist/non-layer.mjs +63 -0
- package/dist/rule.cjs +8 -708
- package/dist/rule.d.ts +6 -147
- package/dist/rule.mjs +8 -708
- package/dist/shared/utils/find-native-css-rule-index.cjs +12 -0
- package/dist/shared/utils/find-native-css-rule-index.mjs +10 -0
- package/dist/syntax-layer.cjs +291 -0
- package/dist/syntax-layer.d.ts +17 -0
- package/dist/syntax-layer.mjs +289 -0
- package/dist/syntax-rule-type.cjs +27 -0
- package/dist/syntax-rule-type.d.ts +28 -0
- package/dist/syntax-rule-type.mjs +25 -0
- package/dist/syntax-rule.cjs +717 -0
- package/dist/syntax-rule.d.ts +47 -0
- package/dist/syntax-rule.mjs +715 -0
- package/dist/types/config.cjs +2 -0
- package/dist/types/config.d.ts +70 -0
- package/dist/types/config.mjs +1 -0
- package/dist/types/syntax.cjs +2 -0
- package/dist/types/syntax.d.ts +106 -0
- package/dist/types/syntax.mjs +1 -0
- package/dist/utils/are-rule-at-equal.cjs +7 -7
- package/dist/utils/are-rule-at-equal.d.ts +2 -2
- package/dist/utils/are-rule-at-equal.mjs +7 -7
- package/dist/utils/are-rule-modes-equal.cjs +2 -2
- package/dist/utils/are-rule-modes-equal.d.ts +2 -2
- package/dist/utils/are-rule-modes-equal.mjs +2 -2
- package/dist/utils/are-rule-selectors-equal.cjs +11 -11
- package/dist/utils/are-rule-selectors-equal.d.ts +2 -2
- package/dist/utils/are-rule-selectors-equal.mjs +11 -11
- package/dist/utils/are-rule-states-equal.cjs +2 -2
- package/dist/utils/are-rule-states-equal.d.ts +2 -2
- package/dist/utils/are-rule-states-equal.mjs +2 -2
- package/dist/utils/are-rules-duplicated.cjs +17 -0
- package/dist/utils/are-rules-duplicated.d.ts +2 -0
- package/dist/utils/are-rules-duplicated.mjs +15 -0
- package/dist/utils/autofill-solid-style.d.ts +2 -2
- package/dist/utils/extend-config.cjs +5 -5
- package/dist/utils/extend-config.d.ts +1 -1
- package/dist/utils/extend-config.mjs +5 -5
- package/dist/utils/generate-css.cjs +1 -1
- package/dist/utils/generate-css.mjs +1 -1
- package/dist/utils/is-core-rule.cjs +2 -2
- package/dist/utils/is-core-rule.mjs +2 -2
- package/dist/utils/reorder-for-readable-classes.cjs +11 -11
- package/dist/utils/reorder-for-readable-classes.mjs +11 -11
- package/package.json +1 -1
- package/dist/config/syntaxes.d.ts +0 -282
- package/dist/utils/are-syntaxes-duplicated.cjs +0 -17
- package/dist/utils/are-syntaxes-duplicated.d.ts +0 -2
- package/dist/utils/are-syntaxes-duplicated.mjs +0 -15
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { PropertiesHyphen } from 'csstype';
|
|
2
|
+
import type SyntaxRuleType from '../syntax-rule-type';
|
|
3
|
+
import type { SyntaxRule } from '../syntax-rule';
|
|
4
|
+
import type { ValueComponent } from './syntax';
|
|
5
|
+
import type { rules, utilities } from '../config';
|
|
6
|
+
export interface SyntaxRuleDefinition {
|
|
7
|
+
type?: SyntaxRuleType;
|
|
8
|
+
matcher?: RegExp;
|
|
9
|
+
sign?: string;
|
|
10
|
+
key?: string;
|
|
11
|
+
subkey?: string;
|
|
12
|
+
ambiguousKeys?: string[];
|
|
13
|
+
ambiguousValues?: (RegExp | string)[];
|
|
14
|
+
variables?: string[];
|
|
15
|
+
separators?: string[];
|
|
16
|
+
unit?: any;
|
|
17
|
+
declarations?: PropertiesHyphen;
|
|
18
|
+
includeAnimations?: boolean;
|
|
19
|
+
analyze?: (this: SyntaxRule, className: string) => [valueToken: string, prefixToken?: string];
|
|
20
|
+
transformValue?(this: SyntaxRule, value: string): string;
|
|
21
|
+
transformValueComponents?(this: SyntaxRule, valueComponents: ValueComponent[]): ValueComponent[];
|
|
22
|
+
declare?(this: SyntaxRule, value: string, valueComponents: ValueComponent[]): PropertiesHyphen;
|
|
23
|
+
delete?(this: SyntaxRule, className: string): void;
|
|
24
|
+
create?(this: SyntaxRule, className: string): void;
|
|
25
|
+
insert?(this: SyntaxRule): void;
|
|
26
|
+
}
|
|
27
|
+
export type VariableValue = number | string | false | (number | string)[];
|
|
28
|
+
export type VariableDefinition = {
|
|
29
|
+
[key in '' | `@${string}` | string]?: VariableValue | VariableDefinition;
|
|
30
|
+
} | VariableValue;
|
|
31
|
+
export type CSSKeyframes = Record<'from' | 'to' | string, PropertiesHyphen>;
|
|
32
|
+
export type AnimationDefinitions = Record<string, CSSKeyframes>;
|
|
33
|
+
export type SelectorDefinitions = Record<string, string | string[]>;
|
|
34
|
+
export interface AtDefinitions {
|
|
35
|
+
[key: string]: number | string | AtDefinitions;
|
|
36
|
+
}
|
|
37
|
+
export interface StyleDefinitions {
|
|
38
|
+
[key: string]: string | StyleDefinitions;
|
|
39
|
+
}
|
|
40
|
+
export type SyntaxRuleDefinitions = Partial<Record<keyof typeof rules | string, SyntaxRuleDefinition>>;
|
|
41
|
+
export type VariableDefinitions = {
|
|
42
|
+
[key in keyof typeof rules]?: VariableDefinition;
|
|
43
|
+
} & Record<string, VariableDefinition>;
|
|
44
|
+
export type UtilityDefinitions = {
|
|
45
|
+
[key in keyof typeof utilities]?: PropertiesHyphen;
|
|
46
|
+
} & Record<string, PropertiesHyphen>;
|
|
47
|
+
export type ModeDefinitions = Record<string, 'class' | 'media' | 'host' | false>;
|
|
48
|
+
export interface FunctionDefinition {
|
|
49
|
+
unit?: string;
|
|
50
|
+
transform?(this: SyntaxRule, value: string, bypassVariableNames: string[]): string | ValueComponent[];
|
|
51
|
+
}
|
|
52
|
+
export type FunctionDefinitions = Record<string, FunctionDefinition>;
|
|
53
|
+
export interface Config {
|
|
54
|
+
extends?: (Config | any)[];
|
|
55
|
+
components?: StyleDefinitions;
|
|
56
|
+
at?: AtDefinitions;
|
|
57
|
+
selectors?: SelectorDefinitions;
|
|
58
|
+
utilities?: UtilityDefinitions;
|
|
59
|
+
variables?: VariableDefinitions;
|
|
60
|
+
rules?: SyntaxRuleDefinitions;
|
|
61
|
+
rootSize?: number;
|
|
62
|
+
baseUnit?: number;
|
|
63
|
+
defaultMode?: 'light' | 'dark' | string | false;
|
|
64
|
+
scope?: string;
|
|
65
|
+
important?: boolean;
|
|
66
|
+
override?: boolean;
|
|
67
|
+
functions?: FunctionDefinitions;
|
|
68
|
+
animations?: AnimationDefinitions;
|
|
69
|
+
modes?: ModeDefinitions;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { SyntaxRuleDefinition } from './config';
|
|
2
|
+
export type AtComponent = AtArbitraryComponent | AtFeatureComponent | AtOperatorComponent;
|
|
3
|
+
export interface AtArbitraryComponent {
|
|
4
|
+
type: 'arbitrary';
|
|
5
|
+
token?: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AtFeatureComponent {
|
|
9
|
+
type: 'feature';
|
|
10
|
+
token?: string;
|
|
11
|
+
name: string;
|
|
12
|
+
valueType: 'number' | 'string';
|
|
13
|
+
value: string | number;
|
|
14
|
+
unit?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AtOperatorComponent {
|
|
17
|
+
type: 'operator';
|
|
18
|
+
token: '&';
|
|
19
|
+
value: 'and';
|
|
20
|
+
}
|
|
21
|
+
export type ValueComponent = StringValueComponent | NumericValueComponent | FunctionValueComponent | VariableValueComponent | SeparatorValueComponent;
|
|
22
|
+
export interface StringValueComponent {
|
|
23
|
+
text?: string;
|
|
24
|
+
token: string;
|
|
25
|
+
type: 'string';
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
export interface NumericValueComponent {
|
|
29
|
+
text?: string;
|
|
30
|
+
token: string;
|
|
31
|
+
type: 'number';
|
|
32
|
+
value: number;
|
|
33
|
+
unit?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface FunctionValueComponent {
|
|
36
|
+
text?: string;
|
|
37
|
+
token: string;
|
|
38
|
+
type: 'function';
|
|
39
|
+
name: string;
|
|
40
|
+
symbol: string;
|
|
41
|
+
children: ValueComponent[];
|
|
42
|
+
bypassTransform?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface VariableValueComponent {
|
|
45
|
+
text?: string;
|
|
46
|
+
token: string;
|
|
47
|
+
type: 'variable';
|
|
48
|
+
name: string;
|
|
49
|
+
alpha?: string;
|
|
50
|
+
fallback?: string;
|
|
51
|
+
variable?: Variable;
|
|
52
|
+
}
|
|
53
|
+
export interface SeparatorValueComponent {
|
|
54
|
+
text?: string;
|
|
55
|
+
token: string;
|
|
56
|
+
type: 'separator';
|
|
57
|
+
value: string;
|
|
58
|
+
}
|
|
59
|
+
export interface DefinedRule {
|
|
60
|
+
id: string;
|
|
61
|
+
key?: string;
|
|
62
|
+
keys: string[];
|
|
63
|
+
matchers: {
|
|
64
|
+
key?: RegExp;
|
|
65
|
+
variable?: RegExp;
|
|
66
|
+
value?: RegExp;
|
|
67
|
+
arbitrary?: RegExp;
|
|
68
|
+
};
|
|
69
|
+
variables: Record<string, Variable>;
|
|
70
|
+
order: number;
|
|
71
|
+
definition: SyntaxRuleDefinition;
|
|
72
|
+
}
|
|
73
|
+
export type MediaFeatureComponent = {
|
|
74
|
+
type: string;
|
|
75
|
+
tokenType?: string;
|
|
76
|
+
operator?: string;
|
|
77
|
+
value: number;
|
|
78
|
+
unit: string;
|
|
79
|
+
};
|
|
80
|
+
export interface MediaQuery {
|
|
81
|
+
token: string;
|
|
82
|
+
features: Record<string, MediaFeatureComponent>;
|
|
83
|
+
type?: string;
|
|
84
|
+
}
|
|
85
|
+
type VariableCommon = {
|
|
86
|
+
group?: string;
|
|
87
|
+
name: string;
|
|
88
|
+
key: string;
|
|
89
|
+
modes?: Record<string, TypeVariable>;
|
|
90
|
+
};
|
|
91
|
+
export interface StringVariable {
|
|
92
|
+
type: 'string';
|
|
93
|
+
value: string;
|
|
94
|
+
}
|
|
95
|
+
export interface NumberVariable {
|
|
96
|
+
type: 'number';
|
|
97
|
+
value: number;
|
|
98
|
+
}
|
|
99
|
+
export interface ColorVariable {
|
|
100
|
+
type: 'color';
|
|
101
|
+
value: string;
|
|
102
|
+
space: 'rgb' | 'hsl';
|
|
103
|
+
}
|
|
104
|
+
export type TypeVariable = StringVariable | NumberVariable | ColorVariable;
|
|
105
|
+
export type Variable = TypeVariable & VariableCommon;
|
|
106
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function areRuleAtEqual(
|
|
4
|
-
const aQueryTypes = Object.keys(
|
|
5
|
-
const bQueryTypes = Object.keys(
|
|
3
|
+
function areRuleAtEqual(aSyntaxRule, bSyntaxRule) {
|
|
4
|
+
const aQueryTypes = Object.keys(aSyntaxRule.at);
|
|
5
|
+
const bQueryTypes = Object.keys(bSyntaxRule.at);
|
|
6
6
|
if (aQueryTypes.length !== bQueryTypes.length) {
|
|
7
7
|
return false;
|
|
8
8
|
}
|
|
9
9
|
for (const aQueryType of aQueryTypes){
|
|
10
|
-
const aAtComponents =
|
|
11
|
-
const bAtComponents =
|
|
10
|
+
const aAtComponents = aSyntaxRule.at[aQueryType];
|
|
11
|
+
const bAtComponents = bSyntaxRule.at[aQueryType];
|
|
12
12
|
for (const aAtComponent of aAtComponents){
|
|
13
|
-
const aAtComponentToken =
|
|
14
|
-
if (!bAtComponents.find((bAtComponent)=>
|
|
13
|
+
const aAtComponentToken = aSyntaxRule.resolveAtComponent(aAtComponent);
|
|
14
|
+
if (!bAtComponents.find((bAtComponent)=>bSyntaxRule.resolveAtComponent(bAtComponent) === aAtComponentToken)) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function areRuleAtEqual(
|
|
1
|
+
import type { SyntaxRule } from '../syntax-rule';
|
|
2
|
+
export default function areRuleAtEqual(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): boolean;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function areRuleAtEqual(
|
|
2
|
-
const aQueryTypes = Object.keys(
|
|
3
|
-
const bQueryTypes = Object.keys(
|
|
1
|
+
function areRuleAtEqual(aSyntaxRule, bSyntaxRule) {
|
|
2
|
+
const aQueryTypes = Object.keys(aSyntaxRule.at);
|
|
3
|
+
const bQueryTypes = Object.keys(bSyntaxRule.at);
|
|
4
4
|
if (aQueryTypes.length !== bQueryTypes.length) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
7
|
for (const aQueryType of aQueryTypes){
|
|
8
|
-
const aAtComponents =
|
|
9
|
-
const bAtComponents =
|
|
8
|
+
const aAtComponents = aSyntaxRule.at[aQueryType];
|
|
9
|
+
const bAtComponents = bSyntaxRule.at[aQueryType];
|
|
10
10
|
for (const aAtComponent of aAtComponents){
|
|
11
|
-
const aAtComponentToken =
|
|
12
|
-
if (!bAtComponents.find((bAtComponent)=>
|
|
11
|
+
const aAtComponentToken = aSyntaxRule.resolveAtComponent(aAtComponent);
|
|
12
|
+
if (!bAtComponents.find((bAtComponent)=>bSyntaxRule.resolveAtComponent(bAtComponent) === aAtComponentToken)) {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function areRuleModesEqual(
|
|
1
|
+
import type { SyntaxRule } from '../syntax-rule';
|
|
2
|
+
export default function areRuleModesEqual(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): boolean;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function areRuleSelectorsEqual(
|
|
3
|
+
function areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) {
|
|
4
4
|
// suffix
|
|
5
|
-
const aVendorSuffixSelectorKeys = Object.keys(
|
|
6
|
-
const bVendorSuffixSelectorKeys = Object.keys(
|
|
5
|
+
const aVendorSuffixSelectorKeys = Object.keys(aSyntaxRule.vendorSuffixSelectors);
|
|
6
|
+
const bVendorSuffixSelectorKeys = Object.keys(bSyntaxRule.vendorSuffixSelectors);
|
|
7
7
|
if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
|
|
8
8
|
const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
|
|
9
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
10
|
-
const aValues =
|
|
11
|
-
const bValues =
|
|
9
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorSuffixSelectors, eachAKey)) return false;
|
|
10
|
+
const aValues = aSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
11
|
+
const bValues = bSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
12
12
|
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
13
13
|
});
|
|
14
14
|
if (!isSameVendorSuffixSelectors) return false;
|
|
15
15
|
// prefix
|
|
16
|
-
const aVendorPrefixSelectorKeys = Object.keys(
|
|
17
|
-
const bVendorPrefixSelectorKeys = Object.keys(
|
|
16
|
+
const aVendorPrefixSelectorKeys = Object.keys(aSyntaxRule.vendorPrefixSelectors);
|
|
17
|
+
const bVendorPrefixSelectorKeys = Object.keys(bSyntaxRule.vendorPrefixSelectors);
|
|
18
18
|
if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
|
|
19
19
|
const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
|
|
20
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
21
|
-
const aValues =
|
|
22
|
-
const bValues =
|
|
20
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorPrefixSelectors, eachAKey)) return false;
|
|
21
|
+
const aValues = aSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
22
|
+
const bValues = bSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
23
23
|
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
24
24
|
});
|
|
25
25
|
if (!isSameVendorPrefixSelectors) return false;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function areRuleSelectorsEqual(
|
|
1
|
+
import type { SyntaxRule } from '../syntax-rule';
|
|
2
|
+
export default function areRuleSelectorsEqual(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): boolean;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
function areRuleSelectorsEqual(
|
|
1
|
+
function areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) {
|
|
2
2
|
// suffix
|
|
3
|
-
const aVendorSuffixSelectorKeys = Object.keys(
|
|
4
|
-
const bVendorSuffixSelectorKeys = Object.keys(
|
|
3
|
+
const aVendorSuffixSelectorKeys = Object.keys(aSyntaxRule.vendorSuffixSelectors);
|
|
4
|
+
const bVendorSuffixSelectorKeys = Object.keys(bSyntaxRule.vendorSuffixSelectors);
|
|
5
5
|
if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
|
|
6
6
|
const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
|
|
7
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
8
|
-
const aValues =
|
|
9
|
-
const bValues =
|
|
7
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorSuffixSelectors, eachAKey)) return false;
|
|
8
|
+
const aValues = aSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
9
|
+
const bValues = bSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
10
10
|
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
11
11
|
});
|
|
12
12
|
if (!isSameVendorSuffixSelectors) return false;
|
|
13
13
|
// prefix
|
|
14
|
-
const aVendorPrefixSelectorKeys = Object.keys(
|
|
15
|
-
const bVendorPrefixSelectorKeys = Object.keys(
|
|
14
|
+
const aVendorPrefixSelectorKeys = Object.keys(aSyntaxRule.vendorPrefixSelectors);
|
|
15
|
+
const bVendorPrefixSelectorKeys = Object.keys(bSyntaxRule.vendorPrefixSelectors);
|
|
16
16
|
if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
|
|
17
17
|
const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
|
|
18
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
19
|
-
const aValues =
|
|
20
|
-
const bValues =
|
|
18
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorPrefixSelectors, eachAKey)) return false;
|
|
19
|
+
const aValues = aSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
20
|
+
const bValues = bSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
21
21
|
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
22
22
|
});
|
|
23
23
|
if (!isSameVendorPrefixSelectors) return false;
|
|
@@ -4,8 +4,8 @@ var areRuleSelectorsEqual = require('./are-rule-selectors-equal.cjs');
|
|
|
4
4
|
var areRuleModesEqual = require('./are-rule-modes-equal.cjs');
|
|
5
5
|
var areRuleAtEqual = require('./are-rule-at-equal.cjs');
|
|
6
6
|
|
|
7
|
-
function areRuleStatesEqual(
|
|
8
|
-
return areRuleSelectorsEqual(
|
|
7
|
+
function areRuleStatesEqual(aSyntaxRule, bSyntaxRule) {
|
|
8
|
+
return areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) && areRuleModesEqual(aSyntaxRule, bSyntaxRule) && areRuleAtEqual(aSyntaxRule, bSyntaxRule);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
module.exports = areRuleStatesEqual;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export default function areRuleStatesEqual(
|
|
1
|
+
import type { SyntaxRule } from '../syntax-rule';
|
|
2
|
+
export default function areRuleStatesEqual(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): boolean;
|
|
@@ -2,8 +2,8 @@ import areRuleSelectorsEqual from './are-rule-selectors-equal.mjs';
|
|
|
2
2
|
import areRuleModesEqual from './are-rule-modes-equal.mjs';
|
|
3
3
|
import areRuleAtEqual from './are-rule-at-equal.mjs';
|
|
4
4
|
|
|
5
|
-
function areRuleStatesEqual(
|
|
6
|
-
return areRuleSelectorsEqual(
|
|
5
|
+
function areRuleStatesEqual(aSyntaxRule, bSyntaxRule) {
|
|
6
|
+
return areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) && areRuleModesEqual(aSyntaxRule, bSyntaxRule) && areRuleAtEqual(aSyntaxRule, bSyntaxRule);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { areRuleStatesEqual as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function areRulesDuplicated(aSyntaxRule, bSyntaxRule) {
|
|
4
|
+
const aKeys = Object.keys(aSyntaxRule.declarations || {});
|
|
5
|
+
const bKeys = Object.keys(bSyntaxRule.declarations || {});
|
|
6
|
+
if (aKeys.length !== bKeys.length) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
for (const key of aKeys){
|
|
10
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.declarations, key)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = areRulesDuplicated;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function areRulesDuplicated(aSyntaxRule, bSyntaxRule) {
|
|
2
|
+
const aKeys = Object.keys(aSyntaxRule.declarations || {});
|
|
3
|
+
const bKeys = Object.keys(bSyntaxRule.declarations || {});
|
|
4
|
+
if (aKeys.length !== bKeys.length) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
for (const key of aKeys){
|
|
8
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.declarations, key)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { areRulesDuplicated as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const autofillSolidStyle:
|
|
1
|
+
import { SyntaxRuleDefinition } from '../types/config';
|
|
2
|
+
declare const autofillSolidStyle: SyntaxRuleDefinition['transformValueComponents'];
|
|
3
3
|
export default autofillSolidStyle;
|
|
@@ -18,8 +18,8 @@ function extendConfig(...configs) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
if (clonedConfig.
|
|
22
|
-
formatDeeply(clonedConfig.
|
|
21
|
+
if (clonedConfig.components) {
|
|
22
|
+
formatDeeply(clonedConfig.components);
|
|
23
23
|
}
|
|
24
24
|
if (clonedConfig.at) {
|
|
25
25
|
formatDeeply(clonedConfig.at);
|
|
@@ -43,7 +43,7 @@ function extendConfig(...configs) {
|
|
|
43
43
|
}
|
|
44
44
|
let extendedConfig = {
|
|
45
45
|
animations: {},
|
|
46
|
-
|
|
46
|
+
components: {},
|
|
47
47
|
at: {},
|
|
48
48
|
variables: {}
|
|
49
49
|
};
|
|
@@ -62,8 +62,8 @@ function extendConfig(...configs) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.
|
|
66
|
-
// Object.assign(extendedConfig.
|
|
65
|
+
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.components, key)) {
|
|
66
|
+
// Object.assign(extendedConfig.components[key], currentFormattedConfig.components[key])
|
|
67
67
|
// }
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Config } from '../config';
|
|
1
|
+
import type { Config } from '../types/config';
|
|
2
2
|
export default function extendConfig(...configs: (Config | undefined)[]): Config;
|
|
@@ -16,8 +16,8 @@ function extendConfig(...configs) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
if (clonedConfig.
|
|
20
|
-
formatDeeply(clonedConfig.
|
|
19
|
+
if (clonedConfig.components) {
|
|
20
|
+
formatDeeply(clonedConfig.components);
|
|
21
21
|
}
|
|
22
22
|
if (clonedConfig.at) {
|
|
23
23
|
formatDeeply(clonedConfig.at);
|
|
@@ -41,7 +41,7 @@ function extendConfig(...configs) {
|
|
|
41
41
|
}
|
|
42
42
|
let extendedConfig = {
|
|
43
43
|
animations: {},
|
|
44
|
-
|
|
44
|
+
components: {},
|
|
45
45
|
at: {},
|
|
46
46
|
variables: {}
|
|
47
47
|
};
|
|
@@ -60,8 +60,8 @@ function extendConfig(...configs) {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.
|
|
64
|
-
// Object.assign(extendedConfig.
|
|
63
|
+
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.components, key)) {
|
|
64
|
+
// Object.assign(extendedConfig.components[key], currentFormattedConfig.components[key])
|
|
65
65
|
// }
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var rules = require('../config/rules.cjs');
|
|
4
4
|
|
|
5
5
|
function isCoreRule(id) {
|
|
6
|
-
return Object.hasOwnProperty.call(
|
|
6
|
+
return Object.hasOwnProperty.call(rules, id);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
module.exports = isCoreRule;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var syntaxRuleType = require('../syntax-rule-type.cjs');
|
|
4
4
|
var core = require('../core.cjs');
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -10,16 +10,16 @@ var core = require('../core.cjs');
|
|
|
10
10
|
* @returns consistent classes
|
|
11
11
|
*/ function reorderForReadableClasses(classes, css = new core.default()) {
|
|
12
12
|
css.add(...classes);
|
|
13
|
-
const orderedClasses = css.
|
|
14
|
-
.filter((eachRule)=>eachRule.
|
|
15
|
-
if (a.
|
|
16
|
-
// 如果 a 是
|
|
13
|
+
const orderedClasses = css.generalLayer.rules// 只保留樣式語法相關的 rules, 排除 keyframes 與 variables 在外
|
|
14
|
+
.filter((eachRule)=>eachRule.type).sort((a, b)=>{
|
|
15
|
+
if (a.type === syntaxRuleType.Utility && b.type !== syntaxRuleType.Utility) {
|
|
16
|
+
// 如果 a 是 SyntaxRuleType.Utility 而 b 不是,则 a 应该排在 b 前面
|
|
17
17
|
return -1;
|
|
18
|
-
} else if (a.
|
|
19
|
-
// 如果 b 是
|
|
18
|
+
} else if (a.type !== syntaxRuleType.Utility && b.type === syntaxRuleType.Utility) {
|
|
19
|
+
// 如果 b 是 SyntaxRuleType.Utility 而 a 不是,则 b 应该排在 a 前面
|
|
20
20
|
return 1;
|
|
21
21
|
} else if (a.id !== b.id) {
|
|
22
|
-
return a.
|
|
22
|
+
return a.name.localeCompare(b.name);
|
|
23
23
|
} else {
|
|
24
24
|
// 檢查 vendorSuffixSelectors 是否存在
|
|
25
25
|
const aHasVendorSuffix = a.vendorSuffixSelectors?.['']?.[0];
|
|
@@ -49,13 +49,13 @@ var core = require('../core.cjs');
|
|
|
49
49
|
}
|
|
50
50
|
// 如果 a 和 b 的 id 相同,則按照以下規則排序
|
|
51
51
|
if (a.id === b.id && a.stateToken === b.stateToken) {
|
|
52
|
-
return a.
|
|
52
|
+
return a.name.localeCompare(b.name);
|
|
53
53
|
}
|
|
54
54
|
// 再按照 rule.order 本身來升序排列
|
|
55
55
|
return a.order - b.order;
|
|
56
56
|
}
|
|
57
|
-
}).map((eachRule)=>eachRule.
|
|
58
|
-
css.
|
|
57
|
+
}).map((eachRule)=>eachRule.name);
|
|
58
|
+
css.remove(...classes);
|
|
59
59
|
return orderedClasses;
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SyntaxRuleType from '../syntax-rule-type.mjs';
|
|
2
2
|
import MasterCSS from '../core.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,16 +8,16 @@ import MasterCSS from '../core.mjs';
|
|
|
8
8
|
* @returns consistent classes
|
|
9
9
|
*/ function reorderForReadableClasses(classes, css = new MasterCSS()) {
|
|
10
10
|
css.add(...classes);
|
|
11
|
-
const orderedClasses = css.
|
|
12
|
-
.filter((eachRule)=>eachRule.
|
|
13
|
-
if (a.
|
|
14
|
-
// 如果 a 是
|
|
11
|
+
const orderedClasses = css.generalLayer.rules// 只保留樣式語法相關的 rules, 排除 keyframes 與 variables 在外
|
|
12
|
+
.filter((eachRule)=>eachRule.type).sort((a, b)=>{
|
|
13
|
+
if (a.type === SyntaxRuleType.Utility && b.type !== SyntaxRuleType.Utility) {
|
|
14
|
+
// 如果 a 是 SyntaxRuleType.Utility 而 b 不是,则 a 应该排在 b 前面
|
|
15
15
|
return -1;
|
|
16
|
-
} else if (a.
|
|
17
|
-
// 如果 b 是
|
|
16
|
+
} else if (a.type !== SyntaxRuleType.Utility && b.type === SyntaxRuleType.Utility) {
|
|
17
|
+
// 如果 b 是 SyntaxRuleType.Utility 而 a 不是,则 b 应该排在 a 前面
|
|
18
18
|
return 1;
|
|
19
19
|
} else if (a.id !== b.id) {
|
|
20
|
-
return a.
|
|
20
|
+
return a.name.localeCompare(b.name);
|
|
21
21
|
} else {
|
|
22
22
|
// 檢查 vendorSuffixSelectors 是否存在
|
|
23
23
|
const aHasVendorSuffix = a.vendorSuffixSelectors?.['']?.[0];
|
|
@@ -47,13 +47,13 @@ import MasterCSS from '../core.mjs';
|
|
|
47
47
|
}
|
|
48
48
|
// 如果 a 和 b 的 id 相同,則按照以下規則排序
|
|
49
49
|
if (a.id === b.id && a.stateToken === b.stateToken) {
|
|
50
|
-
return a.
|
|
50
|
+
return a.name.localeCompare(b.name);
|
|
51
51
|
}
|
|
52
52
|
// 再按照 rule.order 本身來升序排列
|
|
53
53
|
return a.order - b.order;
|
|
54
54
|
}
|
|
55
|
-
}).map((eachRule)=>eachRule.
|
|
56
|
-
css.
|
|
55
|
+
}).map((eachRule)=>eachRule.name);
|
|
56
|
+
css.remove(...classes);
|
|
57
57
|
return orderedClasses;
|
|
58
58
|
}
|
|
59
59
|
|