@plumeria/utils 6.1.2 → 6.2.0
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 +55 -19
- package/dist/parser.js +7 -0
- package/package.json +2 -2
package/dist/create.js
CHANGED
|
@@ -20,9 +20,10 @@ function getStyleRecords(key, styleRule, priority = 1 | 2) {
|
|
|
20
20
|
querySheets.push(sheet.replace(`.${hash}`, `.${hash}${notNormalize}`));
|
|
21
21
|
queryHashes.push(hash);
|
|
22
22
|
}
|
|
23
|
+
const queryKey = prop + ':' + innerProp;
|
|
23
24
|
if (querySheets.length > 0) {
|
|
24
25
|
records.push({
|
|
25
|
-
key:
|
|
26
|
+
key: queryKey,
|
|
26
27
|
hash: queryHashes.join(' '),
|
|
27
28
|
sheet: querySheets.join(''),
|
|
28
29
|
});
|
|
@@ -58,29 +59,64 @@ function getStyleRecords(key, styleRule, priority = 1 | 2) {
|
|
|
58
59
|
nonFlatBase[atRule] = nestedObj;
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
const processSelectorStyle = (selector, style, atRule, index) => {
|
|
63
|
+
const isAtomic = selector.startsWith(':') ||
|
|
64
|
+
(selector.startsWith('&') &&
|
|
65
|
+
(selector.startsWith('&:') || selector.startsWith('&[')));
|
|
66
|
+
if (isAtomic) {
|
|
67
|
+
const normalizedSelector = selector.replace('&', '');
|
|
68
|
+
Object.entries(style).forEach(([prop, value]) => {
|
|
69
|
+
let hashSource = { [prop]: value };
|
|
70
|
+
if (atRule) {
|
|
71
|
+
hashSource = { [atRule]: { [selector]: hashSource } };
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
hashSource = { [selector]: hashSource };
|
|
75
|
+
}
|
|
76
|
+
const suffix = atRule ? notNormalize : ':not(#\\#)';
|
|
77
|
+
const hash = (0, zss_engine_1.genBase36Hash)(hashSource, 1, 8);
|
|
78
|
+
let sheet = (0, zss_engine_1.transpileAtomic)(prop, value, hash, normalizedSelector);
|
|
79
|
+
sheet = sheet.replace(`.${hash}`, `.${hash}${suffix}`);
|
|
80
|
+
if (atRule) {
|
|
81
|
+
sheet = `${atRule} { ${sheet} }`;
|
|
82
|
+
}
|
|
83
|
+
records.push({
|
|
84
|
+
key: atRule
|
|
85
|
+
? `${atRule}:${selector}:${prop}`
|
|
86
|
+
: `${selector}:${prop}`,
|
|
87
|
+
hash,
|
|
88
|
+
sheet: sheet + '\n',
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const hashObj = {
|
|
94
|
+
[key]: { [atRule || 'base']: { [selector]: style, index } },
|
|
95
|
+
};
|
|
75
96
|
const hash = (0, zss_engine_1.genBase36Hash)(hashObj, 1, 7);
|
|
76
|
-
const transpileObj =
|
|
97
|
+
const transpileObj = atRule
|
|
98
|
+
? { [key]: { [atRule]: { [selector]: style } } }
|
|
99
|
+
: { [key]: { [selector]: style } };
|
|
77
100
|
const { styleSheet } = (0, zss_engine_1.transpile)(transpileObj, hash);
|
|
78
|
-
const
|
|
101
|
+
const sheet = atRule
|
|
102
|
+
? styleSheet.replace(`.${hash}`, `.${hash}${notNormalize}`)
|
|
103
|
+
: styleSheet;
|
|
104
|
+
const recordKey = atRule
|
|
105
|
+
? `${atRule}:${selector}:${index}`
|
|
106
|
+
: `${selector}:${index}`;
|
|
79
107
|
records.push({
|
|
80
|
-
key:
|
|
108
|
+
key: recordKey,
|
|
81
109
|
hash: hash,
|
|
82
|
-
sheet:
|
|
110
|
+
sheet: sheet,
|
|
83
111
|
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
Object.entries(nonFlatBase).forEach(([selector, style], index) => {
|
|
115
|
+
processSelectorStyle(selector, style, undefined, index);
|
|
116
|
+
});
|
|
117
|
+
Object.entries(nonFlatQuery).forEach(([atRule, nestedStyles]) => {
|
|
118
|
+
Object.entries(nestedStyles).forEach(([selector, style], index) => {
|
|
119
|
+
processSelectorStyle(selector, style, atRule, index);
|
|
84
120
|
});
|
|
85
121
|
});
|
|
86
122
|
}
|
package/dist/parser.js
CHANGED
|
@@ -402,7 +402,11 @@ function resolveThemeTableMemberExpressionByNode(node, themeTable) {
|
|
|
402
402
|
return undefined;
|
|
403
403
|
}
|
|
404
404
|
const fileCache = {};
|
|
405
|
+
let globalAgregatedTables = null;
|
|
405
406
|
function scanAll() {
|
|
407
|
+
if (process.env.NODE_ENV === 'production' && globalAgregatedTables) {
|
|
408
|
+
return globalAgregatedTables;
|
|
409
|
+
}
|
|
406
410
|
const localTables = {
|
|
407
411
|
staticTable: {},
|
|
408
412
|
themeTable: {},
|
|
@@ -688,6 +692,9 @@ function scanAll() {
|
|
|
688
692
|
}
|
|
689
693
|
}
|
|
690
694
|
localTables.extractedSheet = totalExtractedSheets.join('');
|
|
695
|
+
if (process.env.NODE_ENV === 'production') {
|
|
696
|
+
globalAgregatedTables = localTables;
|
|
697
|
+
}
|
|
691
698
|
return localTables;
|
|
692
699
|
}
|
|
693
700
|
function extractOndemandStyles(obj, extractedSheets, t = exports.tables) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Plumeria Utils",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@swc/core": "1.15.8",
|
|
25
|
-
"zss-engine": "2.
|
|
25
|
+
"zss-engine": "2.2.0"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public",
|