@master/css 2.0.0-rc.5 → 2.0.0-rc.50
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/README.md +4 -43
- package/dist/_virtual/_commonjsHelpers.cjs +10 -0
- package/dist/_virtual/_commonjsHelpers.mjs +7 -0
- package/dist/_virtual/css-escape.cjs +5 -0
- package/dist/_virtual/css-escape.mjs +3 -0
- package/dist/bin/index.cjs +11 -0
- package/dist/bin/index.d.ts +0 -1
- package/dist/bin/index.mjs +9 -0
- package/dist/common.cjs +159 -0
- package/dist/common.d.ts +26 -0
- package/dist/common.mjs +137 -0
- package/dist/config/animations.cjs +113 -0
- package/dist/config/animations.mjs +111 -0
- package/dist/config/at.cjs +14 -0
- package/dist/config/at.d.ts +11 -0
- package/dist/config/at.mjs +12 -0
- package/dist/config/functions.cjs +375 -0
- package/dist/config/functions.d.ts +1 -1
- package/dist/config/functions.mjs +373 -0
- package/dist/config/index.cjs +37 -0
- package/dist/config/index.d.ts +5 -62
- package/dist/config/index.mjs +27 -0
- package/dist/config/modes.cjs +8 -0
- package/dist/config/modes.d.ts +3 -0
- package/dist/config/modes.mjs +6 -0
- package/dist/config/rules.cjs +2327 -0
- package/dist/config/rules.d.ts +277 -274
- package/dist/config/rules.mjs +2325 -0
- package/dist/config/selectors.cjs +28 -0
- package/dist/config/selectors.d.ts +0 -1
- package/dist/config/selectors.mjs +26 -0
- package/dist/config/styles.cjs +2 -0
- package/dist/config/styles.d.ts +2 -2
- package/dist/config/styles.mjs +1 -0
- package/dist/config/utilities.cjs +204 -0
- package/dist/config/{semantics.d.ts → utilities.d.ts} +15 -5
- package/dist/config/utilities.mjs +202 -0
- package/dist/config/variables.cjs +484 -0
- package/dist/config/variables.d.ts +208 -312
- package/dist/config/variables.mjs +482 -0
- package/dist/core.cjs +664 -0
- package/dist/core.d.ts +44 -73
- package/dist/core.mjs +659 -0
- package/dist/index.cjs +81 -0
- package/dist/index.d.ts +20 -9
- package/dist/index.mjs +26 -0
- package/dist/layer.cjs +116 -0
- package/dist/layer.d.ts +13 -10
- package/dist/layer.mjs +114 -0
- package/dist/non-layer.cjs +65 -0
- package/dist/non-layer.d.ts +12 -0
- package/dist/non-layer.mjs +63 -0
- package/dist/polyfills/css-escape.cjs +9 -0
- package/dist/polyfills/css-escape.mjs +7 -0
- package/dist/polyfills/css-escape2.cjs +76 -0
- package/dist/polyfills/css-escape2.mjs +74 -0
- package/dist/rule.cjs +18 -0
- package/dist/rule.d.ts +6 -111
- package/dist/rule.mjs +16 -0
- package/dist/shared/utils/css-escape.cjs +56 -0
- package/dist/shared/utils/css-escape.mjs +54 -0
- 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/global.cjs +2 -0
- package/dist/types/global.d.ts +3 -3
- package/dist/types/global.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 +22 -0
- package/dist/utils/are-rule-at-equal.d.ts +2 -0
- package/dist/utils/are-rule-at-equal.mjs +20 -0
- package/dist/utils/are-rule-modes-equal.cjs +7 -0
- package/dist/utils/are-rule-modes-equal.d.ts +2 -0
- package/dist/utils/are-rule-modes-equal.mjs +5 -0
- package/dist/utils/are-rule-selectors-equal.cjs +29 -0
- package/dist/utils/are-rule-selectors-equal.d.ts +2 -0
- package/dist/utils/are-rule-selectors-equal.mjs +27 -0
- package/dist/utils/are-rule-states-equal.cjs +11 -0
- package/dist/utils/are-rule-states-equal.d.ts +2 -0
- package/dist/utils/are-rule-states-equal.mjs +9 -0
- 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.cjs +31 -0
- package/dist/utils/autofill-solid-style.d.ts +3 -0
- package/dist/utils/autofill-solid-style.mjs +29 -0
- package/dist/utils/extend-config.cjs +73 -0
- package/dist/utils/extend-config.d.ts +2 -2
- package/dist/utils/extend-config.mjs +71 -0
- package/dist/utils/flatten-object.cjs +15 -0
- package/dist/utils/flatten-object.mjs +13 -0
- 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 +30 -0
- package/dist/utils/hex-to-rgb.d.ts +1 -1
- package/dist/utils/hex-to-rgb.mjs +28 -0
- 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/utils/reorder-for-readable-classes.cjs +62 -0
- package/dist/{functions → utils}/reorder-for-readable-classes.d.ts +2 -6
- package/dist/utils/reorder-for-readable-classes.mjs +60 -0
- package/package.json +1 -1
- package/dist/bin/index.bundle.js +0 -36
- package/dist/config/media-queries.d.ts +0 -1
- package/dist/constants/base-unit-regex.d.ts +0 -1
- package/dist/constants/config-esm-text.d.ts +0 -1
- package/dist/constants/config-text.d.ts +0 -1
- package/dist/constants/config-ts-text.d.ts +0 -1
- package/dist/constants/start-symbol.d.ts +0 -6
- package/dist/functions/transform-color-with-opacity.d.ts +0 -1
- package/dist/index.bundle.js +0 -35
- package/dist/index.bundle.mjs +0 -35
- package/dist/tokens/screen-sizes.d.ts +0 -14
- package/dist/utils/concat-arrays.d.ts +0 -1
- package/dist/utils/get-type.d.ts +0 -7
- package/dist/utils/is-plain-object.d.ts +0 -8
- package/dist/utils/is-symbol.d.ts +0 -7
- package/dist/utils/rgb-to-hex.d.ts +0 -1
|
@@ -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
|
+
|
package/dist/types/global.d.ts
CHANGED
|
@@ -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
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function areRuleAtEqual(aSyntaxRule, bSyntaxRule) {
|
|
4
|
+
const aQueryTypes = Object.keys(aSyntaxRule.at);
|
|
5
|
+
const bQueryTypes = Object.keys(bSyntaxRule.at);
|
|
6
|
+
if (aQueryTypes.length !== bQueryTypes.length) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
for (const aQueryType of aQueryTypes){
|
|
10
|
+
const aAtComponents = aSyntaxRule.at[aQueryType];
|
|
11
|
+
const bAtComponents = bSyntaxRule.at[aQueryType];
|
|
12
|
+
for (const aAtComponent of aAtComponents){
|
|
13
|
+
const aAtComponentToken = aSyntaxRule.resolveAtComponent(aAtComponent);
|
|
14
|
+
if (!bAtComponents.find((bAtComponent)=>bSyntaxRule.resolveAtComponent(bAtComponent) === aAtComponentToken)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = areRuleAtEqual;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function areRuleAtEqual(aSyntaxRule, bSyntaxRule) {
|
|
2
|
+
const aQueryTypes = Object.keys(aSyntaxRule.at);
|
|
3
|
+
const bQueryTypes = Object.keys(bSyntaxRule.at);
|
|
4
|
+
if (aQueryTypes.length !== bQueryTypes.length) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
for (const aQueryType of aQueryTypes){
|
|
8
|
+
const aAtComponents = aSyntaxRule.at[aQueryType];
|
|
9
|
+
const bAtComponents = bSyntaxRule.at[aQueryType];
|
|
10
|
+
for (const aAtComponent of aAtComponents){
|
|
11
|
+
const aAtComponentToken = aSyntaxRule.resolveAtComponent(aAtComponent);
|
|
12
|
+
if (!bAtComponents.find((bAtComponent)=>bSyntaxRule.resolveAtComponent(bAtComponent) === aAtComponentToken)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { areRuleAtEqual as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) {
|
|
4
|
+
// suffix
|
|
5
|
+
const aVendorSuffixSelectorKeys = Object.keys(aSyntaxRule.vendorSuffixSelectors);
|
|
6
|
+
const bVendorSuffixSelectorKeys = Object.keys(bSyntaxRule.vendorSuffixSelectors);
|
|
7
|
+
if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
|
|
8
|
+
const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
|
|
9
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorSuffixSelectors, eachAKey)) return false;
|
|
10
|
+
const aValues = aSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
11
|
+
const bValues = bSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
12
|
+
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
13
|
+
});
|
|
14
|
+
if (!isSameVendorSuffixSelectors) return false;
|
|
15
|
+
// prefix
|
|
16
|
+
const aVendorPrefixSelectorKeys = Object.keys(aSyntaxRule.vendorPrefixSelectors);
|
|
17
|
+
const bVendorPrefixSelectorKeys = Object.keys(bSyntaxRule.vendorPrefixSelectors);
|
|
18
|
+
if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
|
|
19
|
+
const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
|
|
20
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorPrefixSelectors, eachAKey)) return false;
|
|
21
|
+
const aValues = aSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
22
|
+
const bValues = bSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
23
|
+
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
24
|
+
});
|
|
25
|
+
if (!isSameVendorPrefixSelectors) return false;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = areRuleSelectorsEqual;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) {
|
|
2
|
+
// suffix
|
|
3
|
+
const aVendorSuffixSelectorKeys = Object.keys(aSyntaxRule.vendorSuffixSelectors);
|
|
4
|
+
const bVendorSuffixSelectorKeys = Object.keys(bSyntaxRule.vendorSuffixSelectors);
|
|
5
|
+
if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
|
|
6
|
+
const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
|
|
7
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorSuffixSelectors, eachAKey)) return false;
|
|
8
|
+
const aValues = aSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
9
|
+
const bValues = bSyntaxRule.vendorSuffixSelectors[eachAKey];
|
|
10
|
+
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
11
|
+
});
|
|
12
|
+
if (!isSameVendorSuffixSelectors) return false;
|
|
13
|
+
// prefix
|
|
14
|
+
const aVendorPrefixSelectorKeys = Object.keys(aSyntaxRule.vendorPrefixSelectors);
|
|
15
|
+
const bVendorPrefixSelectorKeys = Object.keys(bSyntaxRule.vendorPrefixSelectors);
|
|
16
|
+
if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
|
|
17
|
+
const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
|
|
18
|
+
if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorPrefixSelectors, eachAKey)) return false;
|
|
19
|
+
const aValues = aSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
20
|
+
const bValues = bSyntaxRule.vendorPrefixSelectors[eachAKey];
|
|
21
|
+
return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
|
|
22
|
+
});
|
|
23
|
+
if (!isSameVendorPrefixSelectors) return false;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { areRuleSelectorsEqual as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var areRuleSelectorsEqual = require('./are-rule-selectors-equal.cjs');
|
|
4
|
+
var areRuleModesEqual = require('./are-rule-modes-equal.cjs');
|
|
5
|
+
var areRuleAtEqual = require('./are-rule-at-equal.cjs');
|
|
6
|
+
|
|
7
|
+
function areRuleStatesEqual(aSyntaxRule, bSyntaxRule) {
|
|
8
|
+
return areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) && areRuleModesEqual(aSyntaxRule, bSyntaxRule) && areRuleAtEqual(aSyntaxRule, bSyntaxRule);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = areRuleStatesEqual;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import areRuleSelectorsEqual from './are-rule-selectors-equal.mjs';
|
|
2
|
+
import areRuleModesEqual from './are-rule-modes-equal.mjs';
|
|
3
|
+
import areRuleAtEqual from './are-rule-at-equal.mjs';
|
|
4
|
+
|
|
5
|
+
function areRuleStatesEqual(aSyntaxRule, bSyntaxRule) {
|
|
6
|
+
return areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) && areRuleModesEqual(aSyntaxRule, bSyntaxRule) && areRuleAtEqual(aSyntaxRule, bSyntaxRule);
|
|
7
|
+
}
|
|
8
|
+
|
|
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 };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var common = require('../common.cjs');
|
|
4
|
+
|
|
5
|
+
const autofillSolidStyle = function(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 = autofillSolidStyle;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BORDER_STYLE_VALUES } from '../common.mjs';
|
|
2
|
+
|
|
3
|
+
const autofillSolidStyle = function(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 { autofillSolidStyle as default };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var extend = require('@techor/extend');
|
|
4
|
+
|
|
5
|
+
// todo: split resolveConfig into a function
|
|
6
|
+
function extendConfig(...configs) {
|
|
7
|
+
const formatConfig = (config)=>{
|
|
8
|
+
const clonedConfig = extend({}, config);
|
|
9
|
+
const formatDeeply = (obj)=>{
|
|
10
|
+
for(const key in obj){
|
|
11
|
+
const value = obj[key];
|
|
12
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
13
|
+
formatDeeply(value);
|
|
14
|
+
} else if (key && !key.startsWith('@')) {
|
|
15
|
+
obj[key] = {
|
|
16
|
+
'': value
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
if (clonedConfig.components) {
|
|
22
|
+
formatDeeply(clonedConfig.components);
|
|
23
|
+
}
|
|
24
|
+
if (clonedConfig.at) {
|
|
25
|
+
formatDeeply(clonedConfig.at);
|
|
26
|
+
}
|
|
27
|
+
if (clonedConfig.variables) {
|
|
28
|
+
formatDeeply(clonedConfig.variables);
|
|
29
|
+
}
|
|
30
|
+
return clonedConfig;
|
|
31
|
+
};
|
|
32
|
+
const formattedConfigs = [];
|
|
33
|
+
for (const eachConfig of configs){
|
|
34
|
+
if (!eachConfig) continue;
|
|
35
|
+
(function getConfigsDeeply(config) {
|
|
36
|
+
if (config.extends?.length) {
|
|
37
|
+
for (const eachExtend of config.extends){
|
|
38
|
+
getConfigsDeeply('config' in eachExtend ? eachExtend.config : eachExtend);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
formattedConfigs.push(formatConfig(config));
|
|
42
|
+
})(eachConfig);
|
|
43
|
+
}
|
|
44
|
+
let extendedConfig = {
|
|
45
|
+
animations: {},
|
|
46
|
+
components: {},
|
|
47
|
+
at: {},
|
|
48
|
+
variables: {}
|
|
49
|
+
};
|
|
50
|
+
for (const currentFormattedConfig of formattedConfigs){
|
|
51
|
+
for(const key in currentFormattedConfig){
|
|
52
|
+
switch(key){
|
|
53
|
+
case 'animations':
|
|
54
|
+
if (currentFormattedConfig.animations) {
|
|
55
|
+
Object.assign(extendedConfig.animations, currentFormattedConfig.animations);
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
if (currentFormattedConfig[key]) {
|
|
60
|
+
extendedConfig = extend(extendedConfig, {
|
|
61
|
+
[key]: currentFormattedConfig[key]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.components, key)) {
|
|
66
|
+
// Object.assign(extendedConfig.components[key], currentFormattedConfig.components[key])
|
|
67
|
+
// }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return extendedConfig;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = extendConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Config } from '../config';
|
|
2
|
-
export
|
|
1
|
+
import type { Config } from '../types/config';
|
|
2
|
+
export default function extendConfig(...configs: (Config | undefined)[]): Config;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import extend from '@techor/extend';
|
|
2
|
+
|
|
3
|
+
// todo: split resolveConfig into a function
|
|
4
|
+
function extendConfig(...configs) {
|
|
5
|
+
const formatConfig = (config)=>{
|
|
6
|
+
const clonedConfig = extend({}, config);
|
|
7
|
+
const formatDeeply = (obj)=>{
|
|
8
|
+
for(const key in obj){
|
|
9
|
+
const value = obj[key];
|
|
10
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
11
|
+
formatDeeply(value);
|
|
12
|
+
} else if (key && !key.startsWith('@')) {
|
|
13
|
+
obj[key] = {
|
|
14
|
+
'': value
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
if (clonedConfig.components) {
|
|
20
|
+
formatDeeply(clonedConfig.components);
|
|
21
|
+
}
|
|
22
|
+
if (clonedConfig.at) {
|
|
23
|
+
formatDeeply(clonedConfig.at);
|
|
24
|
+
}
|
|
25
|
+
if (clonedConfig.variables) {
|
|
26
|
+
formatDeeply(clonedConfig.variables);
|
|
27
|
+
}
|
|
28
|
+
return clonedConfig;
|
|
29
|
+
};
|
|
30
|
+
const formattedConfigs = [];
|
|
31
|
+
for (const eachConfig of configs){
|
|
32
|
+
if (!eachConfig) continue;
|
|
33
|
+
(function getConfigsDeeply(config) {
|
|
34
|
+
if (config.extends?.length) {
|
|
35
|
+
for (const eachExtend of config.extends){
|
|
36
|
+
getConfigsDeeply('config' in eachExtend ? eachExtend.config : eachExtend);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
formattedConfigs.push(formatConfig(config));
|
|
40
|
+
})(eachConfig);
|
|
41
|
+
}
|
|
42
|
+
let extendedConfig = {
|
|
43
|
+
animations: {},
|
|
44
|
+
components: {},
|
|
45
|
+
at: {},
|
|
46
|
+
variables: {}
|
|
47
|
+
};
|
|
48
|
+
for (const currentFormattedConfig of formattedConfigs){
|
|
49
|
+
for(const key in currentFormattedConfig){
|
|
50
|
+
switch(key){
|
|
51
|
+
case 'animations':
|
|
52
|
+
if (currentFormattedConfig.animations) {
|
|
53
|
+
Object.assign(extendedConfig.animations, currentFormattedConfig.animations);
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
if (currentFormattedConfig[key]) {
|
|
58
|
+
extendedConfig = extend(extendedConfig, {
|
|
59
|
+
[key]: currentFormattedConfig[key]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.components, key)) {
|
|
64
|
+
// Object.assign(extendedConfig.components[key], currentFormattedConfig.components[key])
|
|
65
|
+
// }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return extendedConfig;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { extendConfig as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function flattenObject(obj, parentKey = '') {
|
|
4
|
+
return Object.entries(obj).reduce((acc, [key, value])=>{
|
|
5
|
+
const currentKey = parentKey ? `${parentKey}${key ? '-' + key : ''}` : key;
|
|
6
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
7
|
+
Object.assign(acc, flattenObject(value, currentKey));
|
|
8
|
+
} else {
|
|
9
|
+
acc[currentKey] = value;
|
|
10
|
+
}
|
|
11
|
+
return acc;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.flattenObject = flattenObject;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function flattenObject(obj, parentKey = '') {
|
|
2
|
+
return Object.entries(obj).reduce((acc, [key, value])=>{
|
|
3
|
+
const currentKey = parentKey ? `${parentKey}${key ? '-' + key : ''}` : key;
|
|
4
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
5
|
+
Object.assign(acc, flattenObject(value, currentKey));
|
|
6
|
+
} else {
|
|
7
|
+
acc[currentKey] = value;
|
|
8
|
+
}
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { flattenObject };
|