@plumeria/webpack-plugin 0.22.2 → 0.22.4
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/create.js +40 -23
- package/dist/index.js +6 -7
- package/package.json +1 -1
package/dist/create.js
CHANGED
|
@@ -11,31 +11,44 @@ function compileToSingleCSS(object) {
|
|
|
11
11
|
const flat = {};
|
|
12
12
|
const nonFlat = {};
|
|
13
13
|
(0, zss_engine_1.splitAtomicAndNested)(styleObj, flat, nonFlat);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
finalFlat[prop] = flat[prop];
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
let isOverridden = false;
|
|
25
|
-
const shorthands = zss_engine_1.LONG_TO_SHORT[kebab] || [];
|
|
26
|
-
for (let j = i + 1; j < props.length; j++) {
|
|
27
|
-
const futureProp = props[j];
|
|
28
|
-
const futureKebab = (0, zss_engine_1.camelToKebabCase)(futureProp);
|
|
29
|
-
if (shorthands.includes(futureKebab)) {
|
|
30
|
-
isOverridden = true;
|
|
31
|
-
break;
|
|
14
|
+
const overrideLonghand = (style) => {
|
|
15
|
+
const props = Object.keys(style);
|
|
16
|
+
if (props.some((p) => p.startsWith('@'))) {
|
|
17
|
+
const finalStyle = { ...style };
|
|
18
|
+
for (const key of props) {
|
|
19
|
+
if (key.startsWith('@')) {
|
|
20
|
+
finalStyle[key] = overrideLonghand(style[key]);
|
|
32
21
|
}
|
|
33
22
|
}
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
return finalStyle;
|
|
24
|
+
}
|
|
25
|
+
const finalStyle = {};
|
|
26
|
+
for (let i = 0; i < props.length; i++) {
|
|
27
|
+
const prop = props[i];
|
|
28
|
+
const kebab = (0, zss_engine_1.camelToKebabCase)(prop);
|
|
29
|
+
const isShorthand = !!zss_engine_1.SHORTHAND_PROPERTIES[kebab];
|
|
30
|
+
if (isShorthand) {
|
|
31
|
+
finalStyle[prop] = style[prop];
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
let isOverridden = false;
|
|
35
|
+
const shorthands = zss_engine_1.LONG_TO_SHORT[kebab] || [];
|
|
36
|
+
for (let j = i + 1; j < props.length; j++) {
|
|
37
|
+
const futureProp = props[j];
|
|
38
|
+
const futureKebab = (0, zss_engine_1.camelToKebabCase)(futureProp);
|
|
39
|
+
if (shorthands.includes(futureKebab)) {
|
|
40
|
+
isOverridden = true;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (!isOverridden) {
|
|
45
|
+
finalStyle[prop] = style[prop];
|
|
46
|
+
}
|
|
36
47
|
}
|
|
37
48
|
}
|
|
38
|
-
|
|
49
|
+
return finalStyle;
|
|
50
|
+
};
|
|
51
|
+
const finalFlat = overrideLonghand(flat);
|
|
39
52
|
const records = [];
|
|
40
53
|
Object.entries(finalFlat).forEach(([prop, value]) => {
|
|
41
54
|
const hashes = new Set();
|
|
@@ -60,10 +73,14 @@ function compileToSingleCSS(object) {
|
|
|
60
73
|
});
|
|
61
74
|
});
|
|
62
75
|
if (Object.keys(nonFlat).length > 0) {
|
|
63
|
-
const
|
|
76
|
+
const finalNonFlat = {};
|
|
77
|
+
Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
|
|
78
|
+
finalNonFlat[atRule] = overrideLonghand(nestedObj);
|
|
79
|
+
});
|
|
80
|
+
const nonFlatObj = { [key]: finalNonFlat };
|
|
64
81
|
const nonFlatHash = (0, zss_engine_1.genBase36Hash)(nonFlatObj, 1, 7);
|
|
65
82
|
const { styleSheet } = (0, zss_engine_1.transpile)(nonFlatObj, nonFlatHash);
|
|
66
|
-
Object.entries(
|
|
83
|
+
Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
|
|
67
84
|
Object.entries(nestedObj).forEach(([prop]) => {
|
|
68
85
|
records.push({
|
|
69
86
|
key: atRule + prop,
|
package/dist/index.js
CHANGED
|
@@ -86,18 +86,17 @@ class PlumeriaPlugin {
|
|
|
86
86
|
return '';
|
|
87
87
|
}
|
|
88
88
|
const sortedStyles = allStyles.sort((a, b) => (b.lastAccessed || 0) - (a.lastAccessed || 0));
|
|
89
|
-
const latestStyles = sortedStyles[0];
|
|
90
89
|
const keyframeStylesSet = new Set();
|
|
91
90
|
const viewTransitionStylesSet = new Set();
|
|
92
91
|
const tokenStylesSet = new Set();
|
|
93
92
|
const baseStylesSet = new Set();
|
|
94
|
-
if (latestStyles.keyframeStyles?.trim().length > 0)
|
|
95
|
-
keyframeStylesSet.add(latestStyles.keyframeStyles);
|
|
96
|
-
if (latestStyles.viewTransitionStyles?.trim().length > 0)
|
|
97
|
-
viewTransitionStylesSet.add(latestStyles.viewTransitionStyles);
|
|
98
|
-
if (latestStyles.tokenStyles?.trim().length > 0)
|
|
99
|
-
tokenStylesSet.add(latestStyles.tokenStyles);
|
|
100
93
|
for (const s of sortedStyles) {
|
|
94
|
+
if (s.keyframeStyles?.trim().length > 0)
|
|
95
|
+
keyframeStylesSet.add(s.keyframeStyles);
|
|
96
|
+
if (s.viewTransitionStyles?.trim().length > 0)
|
|
97
|
+
viewTransitionStylesSet.add(s.viewTransitionStyles);
|
|
98
|
+
if (s.tokenStyles?.trim().length > 0)
|
|
99
|
+
tokenStylesSet.add(s.tokenStyles);
|
|
101
100
|
if (s.baseStyles?.trim().length > 0)
|
|
102
101
|
baseStylesSet.add(s.baseStyles);
|
|
103
102
|
}
|