@plumeria/unplugin 12.0.1 → 12.0.2
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/core.js +73 -22
- package/dist/core.mjs +73 -22
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -471,6 +471,35 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
471
471
|
};
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
|
+
else if (propName === 'createStatic' &&
|
|
475
|
+
utils_1.t.isObjectExpression(init.arguments[0].expression)) {
|
|
476
|
+
if (utils_1.t.isIdentifier(node.id)) {
|
|
477
|
+
idSpans.add(node.id.span.start);
|
|
478
|
+
}
|
|
479
|
+
const obj = (0, utils_1.objectExpressionToObject)(init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
480
|
+
const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
|
|
481
|
+
if (utils_1.t.isIdentifier(node.id)) {
|
|
482
|
+
const uniqueKey = `${resourcePath}-${node.id.value}`;
|
|
483
|
+
scannedTables.createStaticHashTable[uniqueKey] = hash;
|
|
484
|
+
scannedTables.createStaticObjectTable[hash] = obj;
|
|
485
|
+
mergedCreateStaticHashTable[node.id.value] = hash;
|
|
486
|
+
localCreateStyles[node.id.value] = {
|
|
487
|
+
name: node.id.value,
|
|
488
|
+
type: 'constant',
|
|
489
|
+
obj,
|
|
490
|
+
hashMap: obj,
|
|
491
|
+
isExported,
|
|
492
|
+
initSpan: {
|
|
493
|
+
start: init.span.start - baseByteOffset,
|
|
494
|
+
end: init.span.end - baseByteOffset,
|
|
495
|
+
},
|
|
496
|
+
declSpan: {
|
|
497
|
+
start: declSpan.start - baseByteOffset,
|
|
498
|
+
end: declSpan.end - baseByteOffset,
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
474
503
|
}
|
|
475
504
|
};
|
|
476
505
|
(0, utils_1.traverse)(ast, {
|
|
@@ -591,12 +620,6 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
591
620
|
else {
|
|
592
621
|
scannedTables.createStaticObjectTable[hash] = obj;
|
|
593
622
|
}
|
|
594
|
-
const prefix = propName === 'createTheme' ? 'tm-' : 'st-';
|
|
595
|
-
replacements.push({
|
|
596
|
-
start: node.span.start - baseByteOffset,
|
|
597
|
-
end: node.span.end - baseByteOffset,
|
|
598
|
-
content: JSON.stringify(`${prefix}${hash}`),
|
|
599
|
-
});
|
|
600
623
|
}
|
|
601
624
|
else if (propName === 'create' &&
|
|
602
625
|
args.length > 0 &&
|
|
@@ -1060,6 +1083,29 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1060
1083
|
const varName = node.object.value;
|
|
1061
1084
|
const propName = node.property.value;
|
|
1062
1085
|
const uniqueKey = `${resourcePath}-${varName}`;
|
|
1086
|
+
const localStyle = localCreateStyles[varName];
|
|
1087
|
+
if (localStyle && localStyle.type === 'create') {
|
|
1088
|
+
const atomMap = localStyle.hashMap[propName];
|
|
1089
|
+
if (atomMap) {
|
|
1090
|
+
replacements.push({
|
|
1091
|
+
start: node.span.start - baseByteOffset,
|
|
1092
|
+
end: node.span.end - baseByteOffset,
|
|
1093
|
+
content: `(${JSON.stringify(atomMap)})`,
|
|
1094
|
+
});
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
if (localStyle && localStyle.type === 'variant') {
|
|
1099
|
+
const variantMap = localStyle.hashMap[propName];
|
|
1100
|
+
if (variantMap) {
|
|
1101
|
+
replacements.push({
|
|
1102
|
+
start: node.span.start - baseByteOffset,
|
|
1103
|
+
end: node.span.end - baseByteOffset,
|
|
1104
|
+
content: `(${JSON.stringify(variantMap)})`,
|
|
1105
|
+
});
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1063
1109
|
let hash = scannedTables.createHashTable[uniqueKey];
|
|
1064
1110
|
if (!hash) {
|
|
1065
1111
|
hash = mergedCreateTable[varName];
|
|
@@ -1077,23 +1123,31 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1077
1123
|
});
|
|
1078
1124
|
}
|
|
1079
1125
|
}
|
|
1080
|
-
let themeHash =
|
|
1126
|
+
let themeHash = mergedCreateThemeHashTable[varName];
|
|
1081
1127
|
if (!themeHash) {
|
|
1082
|
-
themeHash =
|
|
1128
|
+
themeHash = scannedTables.createThemeHashTable[uniqueKey];
|
|
1083
1129
|
}
|
|
1084
1130
|
if (themeHash) {
|
|
1085
1131
|
const atomicMap = scannedTables.createAtomicMapTable[themeHash];
|
|
1086
|
-
if (atomicMap && atomicMap
|
|
1132
|
+
if (atomicMap && atomicMap[propName]) {
|
|
1087
1133
|
replacements.push({
|
|
1088
1134
|
start: node.span.start - baseByteOffset,
|
|
1089
1135
|
end: node.span.end - baseByteOffset,
|
|
1090
1136
|
content: `(${JSON.stringify(atomicMap[propName])})`,
|
|
1091
1137
|
});
|
|
1092
1138
|
}
|
|
1139
|
+
else {
|
|
1140
|
+
const cssVarName = (0, zss_engine_1.camelToKebabCase)(propName);
|
|
1141
|
+
replacements.push({
|
|
1142
|
+
start: node.span.start - baseByteOffset,
|
|
1143
|
+
end: node.span.end - baseByteOffset,
|
|
1144
|
+
content: `(${JSON.stringify(`var(--${themeHash}-${cssVarName})`)})`,
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1093
1147
|
}
|
|
1094
|
-
let staticHash =
|
|
1148
|
+
let staticHash = mergedCreateStaticHashTable[varName];
|
|
1095
1149
|
if (!staticHash) {
|
|
1096
|
-
staticHash =
|
|
1150
|
+
staticHash = scannedTables.createStaticHashTable[uniqueKey];
|
|
1097
1151
|
}
|
|
1098
1152
|
if (staticHash) {
|
|
1099
1153
|
const staticObj = scannedTables.createStaticObjectTable[staticHash];
|
|
@@ -1123,9 +1177,9 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1123
1177
|
}
|
|
1124
1178
|
const varName = node.value;
|
|
1125
1179
|
const uniqueKey = `${resourcePath}-${varName}`;
|
|
1126
|
-
let hash =
|
|
1180
|
+
let hash = mergedCreateTable[varName];
|
|
1127
1181
|
if (!hash) {
|
|
1128
|
-
hash =
|
|
1182
|
+
hash = scannedTables.createHashTable[uniqueKey];
|
|
1129
1183
|
}
|
|
1130
1184
|
if (hash) {
|
|
1131
1185
|
const obj = scannedTables.createObjectTable[hash];
|
|
@@ -1144,9 +1198,9 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1144
1198
|
});
|
|
1145
1199
|
}
|
|
1146
1200
|
}
|
|
1147
|
-
let themeHash =
|
|
1201
|
+
let themeHash = mergedCreateThemeHashTable[varName];
|
|
1148
1202
|
if (!themeHash) {
|
|
1149
|
-
themeHash =
|
|
1203
|
+
themeHash = scannedTables.createThemeHashTable[uniqueKey];
|
|
1150
1204
|
}
|
|
1151
1205
|
if (themeHash) {
|
|
1152
1206
|
const atomicMap = scannedTables.createAtomicMapTable[themeHash];
|
|
@@ -1159,9 +1213,9 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1159
1213
|
return;
|
|
1160
1214
|
}
|
|
1161
1215
|
}
|
|
1162
|
-
let staticHash =
|
|
1216
|
+
let staticHash = mergedCreateStaticHashTable[varName];
|
|
1163
1217
|
if (!staticHash) {
|
|
1164
|
-
staticHash =
|
|
1218
|
+
staticHash = scannedTables.createStaticHashTable[uniqueKey];
|
|
1165
1219
|
}
|
|
1166
1220
|
if (staticHash) {
|
|
1167
1221
|
const staticObj = scannedTables.createStaticObjectTable[staticHash];
|
|
@@ -1389,13 +1443,10 @@ const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1389
1443
|
},
|
|
1390
1444
|
});
|
|
1391
1445
|
Object.values(localCreateStyles).forEach((info) => {
|
|
1392
|
-
if (info.type === 'constant') {
|
|
1393
|
-
return;
|
|
1394
|
-
}
|
|
1395
1446
|
if (info.isExported) {
|
|
1396
1447
|
replacements.push({
|
|
1397
|
-
start: info.
|
|
1398
|
-
end: info.
|
|
1448
|
+
start: info.initSpan.start,
|
|
1449
|
+
end: info.initSpan.end,
|
|
1399
1450
|
content: JSON.stringify(''),
|
|
1400
1451
|
});
|
|
1401
1452
|
}
|
package/dist/core.mjs
CHANGED
|
@@ -435,6 +435,35 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
+
else if (propName === 'createStatic' &&
|
|
439
|
+
t.isObjectExpression(init.arguments[0].expression)) {
|
|
440
|
+
if (t.isIdentifier(node.id)) {
|
|
441
|
+
idSpans.add(node.id.span.start);
|
|
442
|
+
}
|
|
443
|
+
const obj = objectExpressionToObject(init.arguments[0].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable, mergedVariantsTable);
|
|
444
|
+
const hash = genBase36Hash(obj, 1, 8);
|
|
445
|
+
if (t.isIdentifier(node.id)) {
|
|
446
|
+
const uniqueKey = `${resourcePath}-${node.id.value}`;
|
|
447
|
+
scannedTables.createStaticHashTable[uniqueKey] = hash;
|
|
448
|
+
scannedTables.createStaticObjectTable[hash] = obj;
|
|
449
|
+
mergedCreateStaticHashTable[node.id.value] = hash;
|
|
450
|
+
localCreateStyles[node.id.value] = {
|
|
451
|
+
name: node.id.value,
|
|
452
|
+
type: 'constant',
|
|
453
|
+
obj,
|
|
454
|
+
hashMap: obj,
|
|
455
|
+
isExported,
|
|
456
|
+
initSpan: {
|
|
457
|
+
start: init.span.start - baseByteOffset,
|
|
458
|
+
end: init.span.end - baseByteOffset,
|
|
459
|
+
},
|
|
460
|
+
declSpan: {
|
|
461
|
+
start: declSpan.start - baseByteOffset,
|
|
462
|
+
end: declSpan.end - baseByteOffset,
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
}
|
|
438
467
|
}
|
|
439
468
|
};
|
|
440
469
|
traverse(ast, {
|
|
@@ -555,12 +584,6 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
555
584
|
else {
|
|
556
585
|
scannedTables.createStaticObjectTable[hash] = obj;
|
|
557
586
|
}
|
|
558
|
-
const prefix = propName === 'createTheme' ? 'tm-' : 'st-';
|
|
559
|
-
replacements.push({
|
|
560
|
-
start: node.span.start - baseByteOffset,
|
|
561
|
-
end: node.span.end - baseByteOffset,
|
|
562
|
-
content: JSON.stringify(`${prefix}${hash}`),
|
|
563
|
-
});
|
|
564
587
|
}
|
|
565
588
|
else if (propName === 'create' &&
|
|
566
589
|
args.length > 0 &&
|
|
@@ -1024,6 +1047,29 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1024
1047
|
const varName = node.object.value;
|
|
1025
1048
|
const propName = node.property.value;
|
|
1026
1049
|
const uniqueKey = `${resourcePath}-${varName}`;
|
|
1050
|
+
const localStyle = localCreateStyles[varName];
|
|
1051
|
+
if (localStyle && localStyle.type === 'create') {
|
|
1052
|
+
const atomMap = localStyle.hashMap[propName];
|
|
1053
|
+
if (atomMap) {
|
|
1054
|
+
replacements.push({
|
|
1055
|
+
start: node.span.start - baseByteOffset,
|
|
1056
|
+
end: node.span.end - baseByteOffset,
|
|
1057
|
+
content: `(${JSON.stringify(atomMap)})`,
|
|
1058
|
+
});
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
if (localStyle && localStyle.type === 'variant') {
|
|
1063
|
+
const variantMap = localStyle.hashMap[propName];
|
|
1064
|
+
if (variantMap) {
|
|
1065
|
+
replacements.push({
|
|
1066
|
+
start: node.span.start - baseByteOffset,
|
|
1067
|
+
end: node.span.end - baseByteOffset,
|
|
1068
|
+
content: `(${JSON.stringify(variantMap)})`,
|
|
1069
|
+
});
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1027
1073
|
let hash = scannedTables.createHashTable[uniqueKey];
|
|
1028
1074
|
if (!hash) {
|
|
1029
1075
|
hash = mergedCreateTable[varName];
|
|
@@ -1041,23 +1087,31 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1041
1087
|
});
|
|
1042
1088
|
}
|
|
1043
1089
|
}
|
|
1044
|
-
let themeHash =
|
|
1090
|
+
let themeHash = mergedCreateThemeHashTable[varName];
|
|
1045
1091
|
if (!themeHash) {
|
|
1046
|
-
themeHash =
|
|
1092
|
+
themeHash = scannedTables.createThemeHashTable[uniqueKey];
|
|
1047
1093
|
}
|
|
1048
1094
|
if (themeHash) {
|
|
1049
1095
|
const atomicMap = scannedTables.createAtomicMapTable[themeHash];
|
|
1050
|
-
if (atomicMap && atomicMap
|
|
1096
|
+
if (atomicMap && atomicMap[propName]) {
|
|
1051
1097
|
replacements.push({
|
|
1052
1098
|
start: node.span.start - baseByteOffset,
|
|
1053
1099
|
end: node.span.end - baseByteOffset,
|
|
1054
1100
|
content: `(${JSON.stringify(atomicMap[propName])})`,
|
|
1055
1101
|
});
|
|
1056
1102
|
}
|
|
1103
|
+
else {
|
|
1104
|
+
const cssVarName = camelToKebabCase(propName);
|
|
1105
|
+
replacements.push({
|
|
1106
|
+
start: node.span.start - baseByteOffset,
|
|
1107
|
+
end: node.span.end - baseByteOffset,
|
|
1108
|
+
content: `(${JSON.stringify(`var(--${themeHash}-${cssVarName})`)})`,
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1057
1111
|
}
|
|
1058
|
-
let staticHash =
|
|
1112
|
+
let staticHash = mergedCreateStaticHashTable[varName];
|
|
1059
1113
|
if (!staticHash) {
|
|
1060
|
-
staticHash =
|
|
1114
|
+
staticHash = scannedTables.createStaticHashTable[uniqueKey];
|
|
1061
1115
|
}
|
|
1062
1116
|
if (staticHash) {
|
|
1063
1117
|
const staticObj = scannedTables.createStaticObjectTable[staticHash];
|
|
@@ -1087,9 +1141,9 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1087
1141
|
}
|
|
1088
1142
|
const varName = node.value;
|
|
1089
1143
|
const uniqueKey = `${resourcePath}-${varName}`;
|
|
1090
|
-
let hash =
|
|
1144
|
+
let hash = mergedCreateTable[varName];
|
|
1091
1145
|
if (!hash) {
|
|
1092
|
-
hash =
|
|
1146
|
+
hash = scannedTables.createHashTable[uniqueKey];
|
|
1093
1147
|
}
|
|
1094
1148
|
if (hash) {
|
|
1095
1149
|
const obj = scannedTables.createObjectTable[hash];
|
|
@@ -1108,9 +1162,9 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1108
1162
|
});
|
|
1109
1163
|
}
|
|
1110
1164
|
}
|
|
1111
|
-
let themeHash =
|
|
1165
|
+
let themeHash = mergedCreateThemeHashTable[varName];
|
|
1112
1166
|
if (!themeHash) {
|
|
1113
|
-
themeHash =
|
|
1167
|
+
themeHash = scannedTables.createThemeHashTable[uniqueKey];
|
|
1114
1168
|
}
|
|
1115
1169
|
if (themeHash) {
|
|
1116
1170
|
const atomicMap = scannedTables.createAtomicMapTable[themeHash];
|
|
@@ -1123,9 +1177,9 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1123
1177
|
return;
|
|
1124
1178
|
}
|
|
1125
1179
|
}
|
|
1126
|
-
let staticHash =
|
|
1180
|
+
let staticHash = mergedCreateStaticHashTable[varName];
|
|
1127
1181
|
if (!staticHash) {
|
|
1128
|
-
staticHash =
|
|
1182
|
+
staticHash = scannedTables.createStaticHashTable[uniqueKey];
|
|
1129
1183
|
}
|
|
1130
1184
|
if (staticHash) {
|
|
1131
1185
|
const staticObj = scannedTables.createStaticObjectTable[staticHash];
|
|
@@ -1353,13 +1407,10 @@ export const unpluginFactory = (options = {}, unpluginMeta) => {
|
|
|
1353
1407
|
},
|
|
1354
1408
|
});
|
|
1355
1409
|
Object.values(localCreateStyles).forEach((info) => {
|
|
1356
|
-
if (info.type === 'constant') {
|
|
1357
|
-
return;
|
|
1358
|
-
}
|
|
1359
1410
|
if (info.isExported) {
|
|
1360
1411
|
replacements.push({
|
|
1361
|
-
start: info.
|
|
1362
|
-
end: info.
|
|
1412
|
+
start: info.initSpan.start,
|
|
1413
|
+
end: info.initSpan.end,
|
|
1363
1414
|
content: JSON.stringify(''),
|
|
1364
1415
|
});
|
|
1365
1416
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/unplugin",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.2",
|
|
4
4
|
"description": "Universal Plumeria plugin for various build tools",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
],
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"unplugin": "^3.0.0",
|
|
89
|
-
"@plumeria/utils": "^12.0.
|
|
89
|
+
"@plumeria/utils": "^12.0.2"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@rollup/pluginutils": "^5.3.0",
|